Skip to content

chore: block secrets with a pre-commit hook and a CI scan - #161

Merged
royosherove merged 2 commits into
mainfrom
chore/secret-scanning
Nov 22, 2026
Merged

royosherove merged 2 commits into
mainfrom
chore/secret-scanning

Conversation

@royosherove

Copy link
Copy Markdown
Member

Stops secrets from being committed or pushed.

Pre-commit hook (husky)

  • prepare: "husky || true": npm ci installs the hook; registry installs of the package don't run prepare, and a missing husky is ignored.
  • .husky/pre-commit runs scripts/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-commit pattern check (Telegram/Anthropic/OpenAI/AWS/npm), which no longer echoes the matched line.
  • .secretlintrc.json allows only the exact fake Slack token shapes used in test/setup-slack*.test.ts and in the error text in src/cli/setup/slack.ts; a realistic Slack token is still blocked.

CI

New secret-scan job in test.yml (push to main and PRs): fetch-depth: 0, gitleaks 8.30.1 downloaded from the GitHub release, sha256 pinned and verified, gitleaks git --redact over the full history. No gitleaks-action.

.gitleaksignore lists 8 fingerprints, all verified false positives: placeholder Slack tokens (A0123456789-1234567890-abcd…, xapp-1-A1-1-abc, xoxa-malformed) in test/setup-slack.test.ts at 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 .npmrc is kept). No tracked file becomes ignored.
  • CONTRIBUTING.md (new), a note in README's Testing section, CLAUDE.md updated.

Verified

  • Demo in a throwaway clone after 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.
  • gitleaks over full history (HEAD and all remote refs): no leaks.
  • npm pack --dry-run file 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 test x4 (2 with temp HOME, 2 plain): 884/884; ~/.roundhouse not created.

- 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.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 22, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-22T07:19:31.763944Z bdc4f17 PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@royosherove
royosherove merged commit 19605ee into main Nov 22, 2026
2 checks passed
@royosherove
royosherove deleted the chore/secret-scanning branch November 22, 2026 07:19

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread .secretlintignore
@@ -0,0 +1,2 @@
node_modules/
package-lock.json

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant