Repository navigation
chore: block secrets with a pre-commit hook and a CI scan - #161
Conversation
- pre-commit (husky): secretlint over the staged blobs, then the existing .githooks pattern check. Works after npm ci, no system binary. - CI: secret-scan job runs pinned, checksum-verified gitleaks 8.30.1 over the full history (fetch-depth: 0). - .gitleaksignore: 8 verified false positives (fake Slack tokens in test/setup-slack.test.ts, commits 141d094 and 16ed51f). - .gitignore: common secret files (keys, certs, nested .npmrc, tokens). - CONTRIBUTING.md and README note on the hook.
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: bdc4f17606
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| @@ -0,0 +1,2 @@ | |||
| node_modules/ | |||
| package-lock.json | |||
There was a problem hiding this comment.
Scan the lockfile for staged secrets
When package-lock.json contains a credential-bearing private dependency URL or another secret, this ignore rule skips it in the staged secretlint scan; the fallback .githooks/pre-commit checks only a few token assignments and key prefixes, so such credentials can pass the pre-commit hook. Scan the lockfile too, or replace this blanket exclusion with targeted suppressions.
Useful? React with 👍 / 👎.
Stops secrets from being committed or pushed.
Pre-commit hook (husky)
prepare: "husky || true":npm ciinstalls the hook; registry installs of the package don't runprepare, and a missing husky is ignored..husky/pre-commitrunsscripts/scan-staged-secrets.sh: it exports the staged blobs (git checkout-index) to a temp dir and scans them with secretlint 13.1.0 +@secretlint/secretlint-rule-preset-recommend(pure npm, no system binary, ~0.3 s). Then it runs the existing.githooks/pre-commitpattern check (Telegram/Anthropic/OpenAI/AWS/npm), which no longer echoes the matched line..secretlintrc.jsonallows only the exact fake Slack token shapes used intest/setup-slack*.test.tsand in the error text insrc/cli/setup/slack.ts; a realistic Slack token is still blocked.CI
New
secret-scanjob intest.yml(push to main and PRs):fetch-depth: 0, gitleaks 8.30.1 downloaded from the GitHub release, sha256 pinned and verified,gitleaks git --redactover the full history. No gitleaks-action..gitleaksignorelists 8 fingerprints, all verified false positives: placeholder Slack tokens (A0123456789-1234567890-abcd…,xapp-1-A1-1-abc,xoxa-malformed) intest/setup-slack.test.tsat commits 141d094 and 16ed51f.Other
.gitignore: keys/certs (*.pem,*.key,*.p12,*.pfx, ssh keys),*.token,credentials.json,service-account*.json,.aws/, nested.npmrc(the tracked root.npmrcis kept). No tracked file becomes ignored.Verified
npm ci: GitHub token, AWS key, realistic Slack token, and a staged secret edited out of the working copy were all blocked; a clean file committed.npm pack --dry-runfile list identical before/after (154 files); no hook/config files ship. Installing the packed tarball in an empty project works.npm ci,npm run typecheck,npm testx4 (2 with temp HOME, 2 plain): 884/884;~/.roundhousenot created.