Repository navigation
mcpx(logging): keep keyword-pair URL values readable in Redact (#2463) - #2833
Conversation
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 7 minutes. View limit details
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 |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0fa59dfb34
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if at < 0 { | ||
| // No userinfo: nothing in this URL is a credential. | ||
| return m, true |
There was a problem hiding this comment.
Redact recognized credentials within preserved URL values
When a keyword-pair URL contains a recognized credential in its query or path, this return bypasses redaction of that credential. For example, Redact("MCPX_SCRIPT_ENV", "AUTH_URL=https://example.com/callback?token=abc123") now returns the input verbatim, whereas the previous implementation returned AUTH_URL=<elided>. Because the keyword-pair regex consumes the entire URL, ReplaceAllStringFunc never separately examines the nested token=abc123 match, exposing it in recorded environment metadata. Preserve URL readability while still redacting recognized credentials within it, and cover this permutation with a regression test.
AGENTS.md reference: pkgs/mcpx/internal/AGENTS.md:L9-L10
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 84be0e32. The preserved URL is now scanned for credentials of its own: credentialInURL (bearer tokens and token literals) applies to the path, and credentialInQuery (KEY=VALUE pairs) applies only from the ?/# separator onward, so a hostname such as auth.example.com:8443 is not mistaken for a pair. AUTH_URL=https://example.com/callback?token=abc123 now records as AUTH_URL=https://example.com/callback?token=<elided> — the URL context survives, the credential does not. Pinned in TestRedactKeywordPairURLValues alongside the path-literal case. The credential shapes are spelled once as constants and composed into all three matchers, so the pair keywords cannot drift between Redact and the nested scan.
Keeping a keyword-pair URL readable must not keep a secret with it: a token pair in its query, or a token literal in its path, is elided now while the URL context survives. The credential shapes are spelled once and composed into every matcher so they cannot drift apart.
Fixes #2463 — PR #1737's
Redactmangled URL values carried under a sensitive keyword.The bug
sensitiveValue's keyword-pair alternative matches a wholeKEY=VALUEtoken before the URL-userinfo alternative can run. The replacement func then applied the userinfo reconstruction to that pair match: it truncated at the first colon after://— the port colon of a credential-free URL — producing a fabricated<elided>@and dropping host/port/path:AUTH_URL=https://auth.example.com:8443/callback→AUTH_URL=https://auth.example.com:<elided>@TOKEN_URL=https://deploy:s3cr3tpw@example.com:8443/path→TOKEN_URL=https://deploy:<elided>@(host/port/path lost)The fix
The replacement func now decides URL-containing matches by shape (
redactURLMatchininternal/logging/trace.go): it locates the scheme, preserves any pair prefix (KEY=/KEY:) or bearer lead-in, and then — no userinfo, or userinfo without a password → the URL is credential-free and kept verbatim; userinfo with a password → only the password is elided, keeping scheme, user, host, port and path. The userinfo reconstruction now applies only to userinfo-shaped matches, as #2463's acceptance requires. No regex changes; whole-value elision for sensitive names is untouched; no generic high-entropy detection added (out of scope per #1710).Tests
84be0e32): keeping a keyword-pair URL readable must not keep a secret with it. The preserved URL is scanned for credentials of its own —credentialInURL(bearer tokens, token literals) applies to the path,credentialInQuery(KEY=VALUE pairs) applies only from the?/#separator soauth.example.com:8443is not read as a pair.AUTH_URL=https://example.com/callback?token=abc123records asAUTH_URL=https://example.com/callback?token=<elided>. The credential shapes are spelled once as constants and composed intosensitiveValue,credentialInURLandcredentialInQuery, so the pair keywords cannot drift between them; pinned in the same test.TestRedactKeywordPairURLValuespins all four shapes (ported credential-free URL, user-only userinfo, password userinfo under a keyword, pair in surrounding context) — reproduced failing 4/4 on main with exactly the mangled outputs mcpx(logging): PR #1737's Redact mangles URL values under a sensitive keyword — port printed as an elided password, rest of URL dropped #2463 reported, now passing.go test ./internal/logging/green on the laptop, including every PR mcpx(logging): fix Redact leaks — full JWT elision, reconciled KEY=VALUE keywords, URL userinfo passwords (#1710) #1737 regression (TestRedactElidesFullJWTAndReconciledKeywords,TestRedactURLUserinfoKeepsTheRestOfTheURL, …). CI runs the same package suite.Queue task 3683 · repo-worker-code Lane A.
Need help on this PR? Tag
@codesmith-botwith what you need.