Skip to content

feat: add trufflehog secret scanning (hooks + CI) - #39

Merged
rohan-naik merged 1 commit into
mainfrom
trufflehog-prehook
Aug 13, 2026
Merged

feat: add trufflehog secret scanning (hooks + CI)#39
rohan-naik merged 1 commit into
mainfrom
trufflehog-prehook

Conversation

@rohan-naik

Copy link
Copy Markdown
Contributor

Adds filesystem secret scanning with trufflehog, wired identically into local git hooks and CI so the two cannot drift apart. Mirrors contentstack/rte-micro-frontend#66.

What's included

  • scripts/trufflehog-scan.sh — the shared scan script. Scans the current filesystem (tracked + untracked, non-gitignored files mirrored into a temp tree), never git history. Mirroring means gitignored local files such as an .npmrc auth token can't fail the hook. It fails closed: an empty scan set, a missing trufflehog, or a broken scan all block rather than pass.
  • .husky/pre-commit and .husky/pre-push — run that script locally. husky added as a devDependency with "prepare": "husky".
  • .github/workflows/secret-scan.yml — runs the same script on PRs and pushes to main. Scans the whole checked-out tree rather than the PR diff: a secret already on the branch is a leak regardless of which commit introduced it.
  • scripts/trufflehog-exclude.txt — excluded paths (node_modules/, dist/, build/, coverage/, package-lock.json, .npmrc).

Difference from the reference PR: the CI push trigger targets main, this repo's default branch, rather than master.

Testing

Verified locally with trufflehog 3.96.0:

Case Result
Clean tree no secrets found, exit 0
Planted realistic AWS key potential secrets found. Aborted., exit 1
Real git commit with that file staged Blocked by husky, no commit created
Real git push pre-push hook ran and passed

Note for reviewers

Developers need trufflehog installed locally (brew install trufflehog) or the hooks will block with install instructions. package-lock.json also carries some npm-generated churn beyond the husky entry, from regenerating against the current tree.

🤖 Generated with Claude Code

Adds filesystem secret scanning with trufflehog, wired identically into
local git hooks and CI so the two cannot drift apart:

- scripts/trufflehog-scan.sh: shared scan script. Scans the current
  filesystem (tracked + untracked, non-gitignored files mirrored into a
  temp tree), never git history. Treats a scan it cannot complete as a
  failure rather than a pass.
- .husky/pre-commit and .husky/pre-push run that script locally.
- .github/workflows/secret-scan.yml runs it on PRs and pushes to main.
- scripts/trufflehog-exclude.txt: excluded paths.

Mirrors contentstack/rte-micro-frontend#66.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@rohan-naik
rohan-naik requested a review from a team as a code owner August 13, 2026 10:10
@snyk-io

snyk-io Bot commented Aug 13, 2026

Copy link
Copy Markdown

Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues
Licenses 0 0 0 0 0 issues
Code Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@github-actions

Copy link
Copy Markdown

🔒 Security Scan Results

ℹ️ Note: Only vulnerabilities with available fixes (upgrades or patches) are counted toward thresholds.

Check Type Count (with fixes) Without fixes Threshold Result
🔴 Critical Severity 0 0 10 ✅ Passed
🟠 High Severity 0 0 25 ✅ Passed
🟡 Medium Severity 0 0 0 ✅ Passed
🔵 Low Severity 0 0 0 ✅ Passed

⏱️ SLA Breach Summary

✅ No SLA breaches detected. All vulnerabilities are within acceptable time thresholds.

Severity Breaches (with fixes) Breaches (no fixes) SLA Threshold (with/no fixes) Status
🔴 Critical 0 0 15 / 30 days ✅ Passed
🟠 High 0 0 30 / 120 days ✅ Passed
🟡 Medium 0 0 90 / 365 days ✅ Passed
🔵 Low 0 0 180 / 365 days ✅ Passed

✅ BUILD PASSED - All security checks passed

@rohan-naik
rohan-naik merged commit c526986 into main Aug 13, 2026
9 of 10 checks passed
@rohan-naik
rohan-naik deleted the trufflehog-prehook branch August 13, 2026 10:15
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.

2 participants