fix(secrets): mask JSON/quoted-key credentials#550
Conversation
the assignment regex expected the separator (: or =) immediately after a sensitive-looking name, so a quoted key put its closing quote between the name and the separator and broke the match. "password": "..." and 'api_key': '...' — the most common structured secret shape, and exactly the file family vouch writes (settings.json, quoted yaml) — slipped through mask_secrets into the gitignored capture buffer that rolls into a committed session page and the append-only audit log. allow an optional closing quote after the name, folded into the captured separator group so the quote is preserved in the output. every currently-masked case still masks; no new false positives (no separator, value under the 6-char floor, or a quoted word without an assignment stay untouched).
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
WalkthroughSecret masking now recognizes JSON and quoted-key credential assignments. Tests cover successful redaction and false-positive cases, and the changelog documents the fix. ChangesSecret masking
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/vouch/secrets.py`:
- Around line 39-43: Update the newly added comment prose in the affected
section of secrets.py so sentence starts remain lowercase, including “the,”
“without,” and “it,” while preserving the existing technical explanation and
code behavior.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: fd62cd8c-5d6a-4f28-993a-f146f55615ce
📒 Files selected for processing (3)
CHANGELOG.mdsrc/vouch/secrets.pytests/test_secrets.py
the added assignment-masking comment started sentences with capitals and used JSON/YAML uppercase; src/vouch/** requires lowercase comment prose. no behaviour change.
What changed
mask_secretsnow catches JSON / quoted-key credentials —"password": "...",'api_key': '...'. one regex change: an optional closing quote after the sensitive-name group, folded into the captured separator so it's preserved in the output.Why
fixes #549. the assignment regex expected the
:/=immediately after the name, so a quoted key put its closing quote between the name and the separator and broke the match. a value that also matches no known token format (a plain password, a short/custom key) then slipped whole. this is the most common structured secret shape and exactly the file family vouch writes —.claude/settings.json(install-adapter json_merge) andconfig.yaml.I drove the real
capture.observepath with{"password": "hunter2supersecret"}:.vouch/captures/<sess>.jsonl— the gitignored buffer that rolls into a committed session page and the append-only audit log[redacted-secret], key name and quotes kept legibleWhat might break
nothing on disk, no
kb.*behaviour change. the change only widens which strings get masked. verified against a matrix: all 3 leaking JSON/quoted-key forms now mask; all 4 currently-masked forms still mask (no regression); and 3 false-positive guards stay untouched — a name with no separator ("password" is required), a value under the 6-char floor (password: hi), and a quoted word without an assignment. the only visible change is that a previously-leaked credential is now redacted, which is the intent.VEP
not a surface change — no
kb.*method, object model, on-disk layout, bundle format or audit-log shape touched.secrets.pyis non-core. no VEP.Tests
make checkpasses locally (lint + mypy + pytest) — 1680 passed, 50 skipped; ruff clean; mypy clean across 104 source filesCHANGELOG.mdupdated under## [Unreleased]test_masks_json_and_quoted_key_credentials— verified failing ontestwithout the src change (the secret leaks); passing with it.test_quoted_key_masking_no_false_positivepins the guards. Also drove the end-to-endcapture.observepipeline both ways to confirm the buffer no longer receives the credential.no ui surface touched, so no screenshots.
Summary by CodeRabbit
Bug Fixes
:).Documentation