fix(transport): redact rpcUrl credentials before logging them - #5586
fix(transport): redact rpcUrl credentials before logging them#5586ntdatt812 wants to merge 1 commit into
Conversation
A connection profile's rpcUrl is stored verbatim -- normalizeRpcUrl keeps
userinfo, query and hash -- so it can carry `user:pass@` or `?token=`.
That is what redactRpcUrlForLog exists for, and its own test pins exactly
that shape:
redactRpcUrlForLog('https://user:pass@host.example/rpc?token=secret#/token')
=== 'https://host.example/rpc'
Four construction-time log lines passed the raw URL instead:
CloudHttpTransport, LanHttpTransport, and both TransportManager
selection branches. With DEBUG=transport:* the credential lands in the
log verbatim.
transport:cloud makes the gap plain: it already reports the bearer token
by presence only ('set' / 'none'), then printed the URL beside it in
full.
Four tests capture what the debug namespaces actually emit and assert
the secrets are absent while the origin+path survives. All four are red
without the src change and green with it.
241 tests pass across services/transport, configPersistence and
coreRpcClient. prettier, eslint and tsc all exit 0.
How this change flows1 changed behaviour across 8 relationships. 4 surrounding behaviours are shown (60 graph nodes walked). 45 further behaviours left out to keep the diagram readable. flowchart LR
n0["TransportManager<br/>changed"]:::changed
n1["getTransport"]:::impacted
n2["manager"]:::impacted
n3["manager"]:::impacted
n4["t"]:::impacted
n2 -->|calls| n0
n2 -->|uses| n0
n2 -->|tests| n0
n3 -->|calls| n0
n3 -->|tests| n0
n4 -->|calls| n1
n4 -->|tests| n1
n4 -->|calls| n2
classDef changed fill:#0d4429,stroke:#238636,color:#e6edf3
classDef impacted fill:#161b22,stroke:#6e7681,color:#c9d1d9
classDef flagged fill:#5a1e02,stroke:#d93f0b,color:#ffffff
classDef blocking fill:#67060c,stroke:#f85149,color:#ffffff
Green: changed behaviour. Grey: surrounding behaviour. Arrows name the call, use, implementation, or test relationship. Orange: has findings. Red: has a finding that blocks the merge. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (4)
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review. 📝 WalkthroughWalkthroughTransport constructors and selection logs now redact credentials and tokens from RPC URLs. New tests verify safe URL logging and secret removal for cloud, LAN, and manager-based transport creation. ChangesTransport log URL redaction
Estimated code review effort: 2 (Simple) | ~10 minutes Merge Risk: ⚪ Minimal · up to The change removes credentials and URL tokens from four transport debug logs without altering transport behavior; no actionable merge-blocking risk remains. Suggested labels: Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
A connection profile's
rpcUrlis stored verbatim —normalizeRpcUrldeliberately keeps query and hash "byte-for-byte intact" and does not touch userinfo — so it can carryuser:pass@or?token=. That is precisely whatredactRpcUrlForLogexists for, and what its own test already pins:Four construction-time log lines passed the raw URL instead of the redacted one:
services/transport/CloudHttpTransport.tsservices/transport/LanHttpTransport.tsservices/transport/TransportManager.tscoreRpcClient.tsandconfigPersistence.tsalready route through the helper; these four were the ones left out.What makes it clear-cut
transport:cloudwas already careful with the other secret on the same line — it reports the bearer token by presence, never by value:So the token is protected and the URL beside it is not.
Reproduction
Captured from the real
debugnamespaces on this branch's parent, withrpcUrl = https://svc:HUNTER2@core.example.com/rpc?token=SUPERSECRET#/tok:Both the password and the query token are in the log line. Anyone with
DEBUG=transport:*— or anyone reading a log a user pastes into an issue — gets them.After the change the same line reads
https://core.example.com/rpc.Verification
app/src/services/transport/logRedaction.test.ts— four tests that capture what the namespaces actually emit (by swappingdebug.log) rather than asserting on the source. They cover both transports and bothTransportManagerselection branches, assert the secrets are absent, and assert the origin+path survives so the log stays useful.Reverting only the three
srcfiles, keeping the test:All four are bug proofs; none of them pass on the old code.
Wider run, using the repo's own config:
prettier --check .,eslint srcandtsc --noEmiteach exit 0.Scope
Deliberately narrow: only the redaction of an already-logged value changes. No log line is added or removed, no behaviour outside logging is touched, and
redactRpcUrlForLogitself is unchanged.Summary by CodeRabbit
Bug Fixes
Tests