Repository navigation
Check for secrets before commit and push - #102
Merged
Merged
Conversation
Before the model runs git commit or git push, scan what it would add to the history: the lines a commit adds (including what a git add in the same command stages) or the commits a push sends. Passwords, keys and tokens in code or configuration, credentials in URLs, private keys, known token forms and .env files are reported with file and line. In ask mode the user decides; in auto-edit and yolo the command doesn't run and the model is told to move the secret out of the code. /commit and /pr show the findings before confirming, and the GitHub Action doesn't commit at all. "lcode: allow-secret" in a comment allows a line; secret_check = false turns it off. Closes #94 Co-Authored-By: Claude Opus 5.5 <[email protected]>
This was referenced Oct 10, 2026
Merged
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.
Closes #94.
In the dahua session, a model committed a camera password in source code, as the default configuration, and pushed it to a public repository. Nothing warned anyone. Cleaning up took a history rewrite and a force-push, and GitHub still serves the old commits.
What changes
lcode.secretscan, before agit commitorgit pushthe model runs, scans what would enter the history:git addin the same command would stage, including untracked files.-aadds the unstaged tracked changes.bash -c "git add . && git commit …",sh -c,eval), lcode can't tell what would be staged, so it scans everything that could be..env, YAML, INI, TOML…), unquoted values too;rtsp://admin:…@);.envfiles, but not.env.example.CHANGE_ME,your_password,<token>,${VAR},…), references (os.environ[…],args.password, paths, URLs), names about a secret (token_url,password_file,max_password_length), and obviously fake values (example,dummy,test…). The report shows file:line with the value masked:cam.py:5: a password or key: "password": "Xk…".askmode: you decide, through a permission prompt of kindsecret; programs get it viaapprove.auto-editandyolo: the command doesn't run, and the model is told to read the secret from the environment or a git-ignored config, and to ask the user if it isn't a secret./commitand/pr: the findings are shown before you confirm;/prasks "Push anyway?".lcode: allow-secret(orgitleaks:allow) in a comment;secret_check = falseturns the check off.secretkind), and the CHANGELOG.git_repoandgithubfixtures moved fromtest_gitflow.pytoconftest.py, sotest_secretscan.pycan use them too.Tests
tests/test_secretscan.py, 31 tests:git add x && git commit, staged changes, and-a;approveassecret;secret_check = falselets it through;/prdeclines to push;Real checks
cam.py:5: a password or key: "password": "Xk…";🤖 Generated with Claude Code