Skip to content

feat: add trufflehog secret scanning - #114

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

feat: add trufflehog secret scanning#114
rohan-naik merged 1 commit into
masterfrom
trufflehog-prehook

Conversation

@rohan-naik

Copy link
Copy Markdown
Contributor

Adds trufflehog-based secret scanning, mirroring contentstack/rte-micro-frontend#66.

What

Secrets are checked at three points, all running the same scripts/trufflehog-scan.sh so CI and developer machines cannot drift apart:

Where Trigger
.husky/pre-commit every git commit
.husky/pre-push every git push
.github/workflows/secret-scan.yml PRs, and pushes to master

The script scans the current filesystem — tracked + untracked non-gitignored files, mirrored into a temp tree — rather than git history or the PR diff. Two consequences worth noting:

  • A secret already present on the branch is reported whether or not this PR introduced it.
  • Gitignored local files (e.g. an .npmrc auth token) are excluded from the scan set, so they cannot fail anyone's hook.

The script fails closed: a missing trufflehog binary, a git/rsync failure, or an empty scan set all abort rather than pass, on the principle that an unverifiable tree is not a clean one.

Deviations from the source PR

Both are repo-specific, not stylistic:

  • prepare was already npm run build (needed for publishing this package), so husky is chained as npm run build && (husky || true) rather than replacing it. The || true keeps npm publish and consumer installs working in checkouts with no git directory.
  • lib/ added to scripts/trufflehog-exclude.txt, as it's this repo's build output.

Testing

Verified locally against both paths:

  • Clean tree → exit 0, no secrets found. The hooks fired on this branch's own commit and push.
  • Planted AWS key → exit 1, secret reported with file and line, commit blocked.

Note that findings come through as unverified when trufflehog can't reach the provider to confirm a key is live; the script still blocks, matching #66 (--results=verified,unknown,unverified). Expect occasional false positives on high-entropy test fixtures — --no-verify is the escape hatch.

The workflow itself is unverified until it runs on this PR; please confirm the Secret Scan check goes green before merging.

Contentstack developers will need brew install trufflehog locally, or their commits will be blocked with install instructions.

🤖 Generated with Claude Code

Add trufflehog-based secret scanning at three points, mirroring
contentstack/rte-micro-frontend#66:

- husky pre-commit and pre-push hooks for local feedback
- a Secret Scan GitHub Actions workflow on PRs and pushes to master

All three run the same scripts/trufflehog-scan.sh so CI and developer
machines cannot drift apart. The script scans the current filesystem
(tracked + untracked, non-gitignored files mirrored to a temp tree)
rather than git history or the PR diff.

Repo-specific deviations from the source PR:
- prepare was already "npm run build" for publishing, so husky is
  chained as "npm run build && (husky || true)" to keep publish and
  consumer installs working where no git dir exists
- lib/ added to the exclude list, as this repo's build output

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 11:31
@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 500 ✅ Passed
🔵 Low Severity 0 0 1000 ✅ 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 7a70cc4 into master Aug 13, 2026
10 checks passed
@rohan-naik
rohan-naik deleted the trufflehog-prehook branch August 13, 2026 11:37
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