[Repo Assist] fix(logger): sanitize secrets in file/server log lines - #10774
Conversation
Closes #10763 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
🔒 mcpg Read-Only Stress — default AWFSurface coverage: MCP tool calls + proxied CLI (REST) + GraphQL mutations
Gateway tool registry: 22 read-only tools exposed; all write tools absent from registry. Overall: PASS References: §31105371023
|
🔒 mcpg Read-Only Stress — gVisorSurface coverage: MCP tool calls + proxied CLI (REST) + GraphQL mutations
Notes:
Overall: PASS ✅ Run: §31105372328
|
🤖 This is an automated pull request from Repo Assist, an AI assistant.
Closes #10763
Root cause
MarkdownLogger.Log()already callssanitize.SanitizeString()on every message before writing togateway.md, redacting tokens/keys/secrets. However,FileLogger.Log()(writes the unifiedmcp-gateway.log) andServerFileLogger.Log()(writes per-server<serverID>.logfiles) both build their log line via the sharedformatLogLine()helper, which did not sanitize the formatted message. This meant secrets logged vialogger.LogInfo,logger.LogWarn,logger.LogError,logger.LogDebug,logger.LogInfoToServer, etc. could leak intomcp-gateway.logand per-server log files even though the markdown log correctly redacted them.Fix
Centralized the fix in
formatLogLine()(shared by bothFileLoggerandServerFileLogger) so the fully-formatted message is passed throughsanitize.SanitizeString()before being returned, mirroring the existingMarkdownLogger.Log()behavior. This ensures secrets are redacted consistently across all three file-based log sinks (unified log, per-server logs, markdown log).Trade-offs
FileLogger/ServerFileLogger(previously onlyMarkdownLoggerpaid this cost). This is consistent with existing behavior elsewhere in the codebase (e.g. RPC message logging already sanitizes once and shares the result across sinks) and is a worthwhile trade-off for closing a secret-leakage gap.formatLogLinesignature and callers are unchanged.Test Status
TestFormatLogLine/secrets_in_the_formatted_message_are_redacted) asserting that a GitHub PAT-shaped string is redacted to[REDACTED]byformatLogLine.gofmtpasses cleanly on both changed files (no diff).go build/go testin this sandbox: the Go module proxy (proxy.golang.org) is blocked by the environment firewall (403 Forbidden on all module downloads, including toolchain and dependency downloads), so the module graph cannot be resolved here. This is an environment/infrastructure limitation, not a defect in the change. The change is a small, syntactically-verified (gofmt -e) addition of a single sanitize call and a corresponding unit test using only existing test patterns already present inglobal_state_test.go; please runmake test/make agent-finishedin CI to confirm.Warning
Firewall blocked 2 domains
The following domains were blocked by the firewall during workflow execution:
goproxy.ioproxy.golang.orgTo allow these domains, add them to the
network.allowedlist in your workflow frontmatter:See Network Configuration for more information.
Add this agentic workflow to your repo
To install this agentic workflow, run