fix(secrets): mask JSON/quoted-key credentials#551
Conversation
Allow an optional closing quote after the sensitive key name so "password": "..." forms redact like bare key=value assignments. Closes vouchdev#549
|
Warning Review limit reached
Next review available in: 29 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
WalkthroughThe secret assignment matcher now handles quoted JSON-style keys before ChangesSecret masking
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
Suggested reviewers: 🚥 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: 2
🤖 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 40-43: Update the _ASSIGNMENT regex and its replacement logic to
match quoted credential values as complete units, including embedded whitespace,
while retaining the opening and closing quote delimiters. Ensure redaction
preserves the original quoted shape so JSON-like assignments remain valid and
unredacted portions cannot leak.
In `@tests/test_secrets.py`:
- Around line 108-119: Add a whitespace-containing quoted credential case to
test_masks_json_quoted_key_credentials, preferably including escaped quotes, and
assert the complete original value is absent from the masked output while the
surrounding quote structure remains intact.
🪄 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: 132d438a-3533-4a21-a941-80c458246ca1
📒 Files selected for processing (2)
src/vouch/secrets.pytests/test_secrets.py
Match double/single-quoted assignment values including whitespace and escapes, and keep the surrounding quotes in the redaction so JSON-shaped output stays valid and cannot leak a trailing token.
Summary
mask_secretsmissed JSON/quoted-key credentials (\"password\": \"...\") because the assignment regex required:/=immediately after the key name, with no room for the key's closing quote.Fold an optional closing quote into the separator group so JSON forms redact while bare
key=value/key: valuekeep working.Closes #549
Test plan
pytest tests/test_secrets.py -q(local if env allows)Made with Cursor
Summary by CodeRabbit
key=valueorkey: valueformats.