ci: replace flaky hardcoded-secrets job with trufflehog-git in Trunk - #746
Conversation
Trunk already runs trufflehog at the PR level (trufflehog@3.90.6 in .trunk/trunk.yaml), alongside a custom mparticle-api-key-check rule, so this job was duplicating secret scanning that Trunk Check already covers. The job was also intermittently red -- 3 failures in 70 recent runs, always in ~5s. It failed on #742 while passing on #743 and #744 with identical config. The cause is in the reusable workflow, which resolves and downloads "latest" trufflehog at runtime by curling the GitHub releases API and grepping the response; that step breaks when the API rate-limits. Trunk pins its trufflehog version and has no runtime download, so it does not share this failure mode. Nothing in the workflow depends on the removed job; no other job referenced it via needs. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
PR SummaryLow Risk Overview Trunk now enables Net effect: fewer flaky CI failures from runtime TruffleHog downloads, pinned tooling, and retained (improved) PR-scoped secret detection without a separate job. Reviewed by Cursor Bugbot for commit 437b884. Bugbot is set up for automated code reviews on this repo. Configure here. |
|
The already-enabled trufflehog linter runs `trufflehog filesystem` against
changed files in the working tree, so it cannot see a secret that was
committed and then removed in a later commit on the same branch -- the file
no longer exists to scan.
trufflehog-git closes that gap. It runs `trufflehog git --since-commit
${upstream-ref}`, walking only the commits the PR adds, so it stays fast
(~1.7s) and does not resurface historical findings.
Demonstrated with a private key committed then removed on a branch:
filesystem scan -> missed it (only the pre-existing daily.yml FP)
git-history scan -> PrivateKey <- probe-key.pem @ f48c6617
Both linters keep Trunk's default --only-verified, so this widens scan
scope, not the reporting threshold.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 437b884. Configure here.




What
Two changes to how secrets get scanned on a PR:
pr-check-hadcoded-secretsjob from.github/workflows/pull-request.yml.trufflehog-git@3.90.6in.trunk/trunk.yaml.Net effect: secret scanning stays at the PR level and gains git-history coverage, while the flaky job goes away.
Why remove the job
It was intermittently red — 3 failures in 70 recent runs, always in ~5s. It failed on #742 while passing on #743 and #744 with identical config.
The cause is in the reusable workflow, which resolves and downloads
latestTruffleHog at runtime:That breaks when the GitHub API rate-limits, which matches the ~5s failure signature. The same script also contains an invalid shell assignment (
$remote_version=$(...)). Trunk pins its TruffleHog version and does no runtime download, so it does not share this failure mode.Why add
trufflehog-git.trunk/trunk.yamlalready enabledtrufflehog@3.90.6, but it runs:That scans changed files in the working tree. If a secret is committed and then removed in a later commit on the same branch, the file no longer exists — so it is never scanned. The removed job did cover that case, because it scanned branch git history with
fetch-depth: 0.trufflehog-gitrestores it:Scoped to the commits the PR adds, so it is fast and does not resurface historical findings.
Verification
Committed a private key on a branch, then removed it in a follow-up commit, and scanned both ways:
filesystem— whattrufflehogalready didgit --since-commit— whattrufflehog-gitaddsPrivateKey ← probe-key.pem @ f48c6617Also confirmed:
trunk check --filter=trufflehog-gitruns clean on this branch in ~1.7s.actionlintand fulltrunk checkpass on both modified files.needs:.Scope note for reviewers
Both linters keep Trunk's default
--only-verified, so TruffleHog reports a secret only when it can validate the credential as live. This PR widens scan scope (working tree → the PR's commits); it does not lower the reporting threshold.The removed job ran without
--only-verifiedand so also reported unverified detections. Measured on a test RSA private key:--only-verified→ 0 findings, default → 1 finding. Restoring that strength is a separate, deliberate change — a full-repo scan without the flag takes 3.4s and surfaces exactly 1 false positive (.github/workflows/daily.yml:54, a SHA-pinned action misread as a 40-hex PAT), so it is cheap if we decide we want it.🤖 Generated with Claude Code