diff --git a/internal/mcp/audit.go b/internal/mcp/audit.go index 80678dc..b5457ff 100644 --- a/internal/mcp/audit.go +++ b/internal/mcp/audit.go @@ -16,7 +16,7 @@ import ( // they identify what a call acted on without copying what it wrote. Every // other argument (file content, issue bodies) is reduced to args_bytes so the // audit trail never becomes a second copy of repo content (gitea-mcp#64). -var auditTargetKeys = []string{"owner", "repo", "number", "branch", "path", "tag"} +var auditTargetKeys = []string{"owner", "repo", "name", "number", "index", "branch", "path", "tag"} // logToolCall emits one structured record per tools/call (OWASP MCP08). func logToolCall(ctx context.Context, name string, args json.RawMessage, start time.Time, err error) { diff --git a/internal/mcp/audit_test.go b/internal/mcp/audit_test.go index 313c01d..d4b42ec 100644 --- a/internal/mcp/audit_test.go +++ b/internal/mcp/audit_test.go @@ -121,3 +121,15 @@ func TestToolsCallAuditOmitsArgumentValuesOtherThanTarget(t *testing.T) { assert.NotContains(t, string(raw), sentinel) assert.Contains(t, recs[0], "args_bytes") } + +// #38 keeps `name` (for repo) and `index` (for number) as legacy aliases; a +// caller using them must still leave a target in the audit record. +func TestToolsCallAuditRecordsLegacyAliasTargets(t *testing.T) { + recs := captureAudit(t, func() { + callTool(t, auditServer(auditStubTool{name: "issue_close"}), "issue_close", + map[string]any{"owner": "mathias", "name": "infra", "index": 7}) + }) + require.Len(t, recs, 1) + assert.Equal(t, "infra", recs[0]["name"]) + assert.EqualValues(t, 7, recs[0]["index"]) +}