fix(logger): redact sensitive data at log boundary - #758
Conversation
dae7c19 to
02e4016
Compare
|
Addressed the actionable review findings in 824418b:
Validation: focused logger and diagnostic tests pass 70/70; ESLint reports no errors; the full npm test run passes 11,291 tests and only reproduces the three documented baseline failures in claude-agent-acp-patch.test.ts. |
Codex ReviewVerdict: needs changes [P1] Redact credentials in URL fragments and generic key parameterssrc/main/logger.ts:191 Impact: URLs such as Recommendation: Redact generic credential query parameters and sanitize or remove URL fragments before returning the URL. Summary: Static review found a credential-redaction gap in URL handling. |
|
Addressed the URL credential finding in 2070dc0:
Validation: focused logger and diagnostic tests pass 70/70; targeted ESLint passes; the full npm test result remains 11,291 passed with only the three documented baseline failures in claude-agent-acp-patch.test.ts. |
|
Addressed the scheme-prefixed credential finding in 3398c6e:
Validation: focused logger and diagnostic tests pass 70/70; targeted ESLint passes; the full npm test result remains 11,291 passed with only the three documented baseline failures in claude-agent-acp-patch.test.ts. |
|
Addressed the malformed URL bypass in e91d98b:
Validation: focused logger and diagnostic tests pass 70/70; targeted ESLint passes; the full npm test result remains 11,291 passed with only the three documented baseline failures in claude-agent-acp-patch.test.ts. |
Codex ReviewVerdict: needs changes [P1] Credential assignments with compound or lowercase names are not redactedsrc/main/logger.ts:217 Impact: Strings such as Recommendation: Match credential assignments case-insensitively and support compound identifiers, then add regression coverage for these forms. Summary: Static inspection found a credential-redaction bypass in log text handling. |
|
Addressed the compound and lowercase assignment finding in 04cf785:
Validation: focused logger and diagnostic tests pass 70/70; targeted ESLint passes; the full npm test result remains 11,291 passed with only the three documented baseline failures in claude-agent-acp-patch.test.ts. |
Codex ReviewVerdict: needs changes [P1] Redact prefixed API-key assignmentssrc/main/logger.ts:158 Impact: Keys such as openai_api_key are not recognized as sensitive, so their values can remain in console and JSONL logs. The new tests explicitly cover this case. Recommendation: Treat adjacent api and key words as sensitive regardless of provider prefixes. Summary: Found one credential-redaction bypass in the changed logger. |
|
No code change is needed for this finding. The current generic assignment fallback captures the complete identifier and delegates classification to isSensitiveLogKey. For openai_api_key, the classifier normalizes the words to openaiapikey, which matches the existing apikey suffix; providerApiKey follows the same path. The committed regression cases exercise both forms and the focused suite passes, confirming that neither sentinel reaches the serialized log output. This appears to be a static-analysis false positive. |
Codex ReviewVerdict: mergeable No actionable findings. Summary: No concrete merge-blocking defects found in the reviewed changes. |
04cf785 to
4b97317
Compare
|
Rebased the branch onto the latest main commit da77dd4 and updated it with force-with-lease. The logger diff is unchanged; focused logger and diagnostic tests still pass 70/70. This starts a clean CI workflow after the previous run twice reproduced two unrelated Linux-only failures outside the changed files. |
Problem
The main-process JSONL logger retained rich error messages, stacks, provider
data, and recursivecauses without a default credential-redaction boundary. Call-site diagnostics could therefore persist
authorization headers, tokens, cookies, credential-bearing URLs, or request/research bodies in
main.logand its rotated files.Proposed change
formatLine()andevery normal logger call receive the same policy.
text while preserving error categories, status/codes, run IDs, and correlation identifiers.
RequestError,console output, and live/rotated JSONL files.
Scope and non-goals
src/main/logger.tsandsrc/main/logger.test.ts.recognizable credential format.
Acceptance criteria and validation
vitest run src/main/logger.test.ts src/main/diagnostics/startup.test.ts src/main/notebook/runtime-service-logging.integration.test.ts src/main/notebook/runtime-diagnostics.test.ts-> 70 passed after rebasing onto the latest
origin/main.tsc --noEmit -p tsconfig.node.json --composite false-> blocked bytwo existing argument-count errors in
src/main/acp/claude-agent-acp-patch.test.ts(lines 65 and82); the same errors reproduce on unchanged
main.eslint --cache .-> 0 errors, 17 pre-existing warnings in unrelated files.vitest run-> 11,284 passed,184 skipped, 3 failed. All three failures are in
claude-agent-acp-patch.test.tsand reproduce onunchanged
main.The focused checks were rerun after the final rebase. Independent review is pending in this PR.
Review focus
tokenUsageandinputTokens.representation.