feat: run the secret scan locally, not only in CI - #74
Merged
Merged
Conversation
scripts/lint-secrets.ts wraps gitleaks the way lint-manifests.ts wraps kubeconform: the binary comes from GITLEAKS or the PATH, and a machine without it skips loudly instead of passing quietly. `npm run verify` runs it, and the secret-scan CI job now runs the same script against the pinned binary it downloads, so one command and one set of patterns serve both.
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 #68 (parent #21)
What this branch does
npm run verifyruns the same secret scan CI runs, so a leaked credential is caught on the machine that wrote it rather than after a push.The scan previously existed only as a CI step with its own command line, so a contributor running the full gate locally got no such check and nothing kept the two in step.
scripts/lint-secrets.tsnow wraps it in the shapelint-manifests.tsuses for kubeconform: the binary comes from theGITLEAKSenvironment variable or from the PATH, and when it is absent the gate skips loudly and exits 0 rather than passing in silence:The workflow calls the same script with the pinned release it downloads, so there is one command and one set of patterns:
REQ-013indocs/requirements.md, count to 13. The Gates table keeps its thirteen gates; only the secret scan's command column changes.One correction
The CI command never passed
--verbose, so a failing scan printed a count and not the file. The acceptance criterion says the failure names the file, and it did not. The script passes--verbose, and it does now.Fixtures
No secret-shaped literal enters the repository. The committed tests drive a stand-in
gitleakswritten into a temporary directory at test time, the way the manifest tests drive a stand-in kubeconform, so the repository never scans its own fixtures. The live check used an untracked planted file, deleted before the commit.Ratchet
Statements 97.88 to 97.94, branches 90.27 to 90.72, functions 100, lines 97.69 to 97.76. README numbers follow, which
lint:docsandREQ-011require.Verification
File: .../tmp-planted-secret.txt,WRN leaks found: 2INF no leaks found; a scanner exiting non-zero fails the build, proven live and in unit tests covering a missing binary, a spawn error and a signal-killed processnpm run verifyclean.actionlint1.7.7, the version CI pins, clean.