Repository navigation
fix: redact secrets before code reaches a model - #15
Merged
Merged
Conversation
guardrails.json declared never_send_secrets_to_llm and redact_patterns, but no code applied them: a diff with a hardcoded key went verbatim to the API prompt and into the agent-mode packet. redact_secrets now runs at both exits, line for line, masking known token formats, private-key bodies and 8+ char literals assigned to secret-like names. The marker keeps the evidence for R7. A test keeps guardrails.json and the patterns in step; no false redactions on the corpus or fixtures. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WkPsqEJ4QYWRW5eCFBYRPS
aisona-lab
marked this pull request as ready for review
October 23, 2026 08:46
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
guardrails.jsondeclarednever_send_secrets_to_llm: trueand listedredact_patterns, but no code applied them. A diff with a hardcoded key went verbatim into the API prompt, and in agent mode intopacket.json. That broke hard rule #2 inAGENTS.md.lazycoder.redact.redact_secretsnow runs at the only two exits:SingleRuleReviewer._build_promptandagent_mode.build_packet. It replaces three kinds of value with<redacted:secret>:sk-…, GitHubghp_/github_pat_, AWSAKIA…, Slackxox?-, GoogleAIza…;-----BEGIN … PRIVATE KEY-----andEND;api_key,secret,token,password/passwdorprivate_key.Design choices
token_type = "bearer", prose,os.environ[...]), so masking can't invite a false R7.guardrails.jsonredact_patternsgets masked.Proof
On real code, 0 redactions across the 37 corpus hunks and the 13 fixtures, so no false positives on what we measure.
Known limit: detection is pattern-based, so a secret in an unusual shape can still get through. The README says so.
Generated by Claude Code