Skip to content

ci: replace flaky hardcoded-secrets job with trufflehog-git in Trunk - #746

Merged
jamesnrokt merged 3 commits into
mainfrom
ci/remove-secrets-scan
Jul 30, 2026
Merged

ci: replace flaky hardcoded-secrets job with trufflehog-git in Trunk#746
jamesnrokt merged 3 commits into
mainfrom
ci/remove-secrets-scan

Conversation

@jamesnrokt

@jamesnrokt jamesnrokt commented Jul 30, 2026

Copy link
Copy Markdown
Collaborator

What

Two changes to how secrets get scanned on a PR:

  1. Remove the pr-check-hadcoded-secrets job from .github/workflows/pull-request.yml.
  2. Enable trufflehog-git@3.90.6 in .trunk/trunk.yaml.
 # .github/workflows/pull-request.yml
-  pr-check-hadcoded-secrets:
-    name: "Check PR for hardcoded secrets"
-    uses: mParticle/mparticle-workflows/.github/workflows/security-hardcoded-secrets.yml@main

 # .trunk/trunk.yaml
     - trufflehog@3.90.6
+    - trufflehog-git@3.90.6

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 latest TruffleHog at runtime:

curl --location "https://api.github.com/repos/trufflesecurity/trufflehog/releases" -o ./releases.json
remotes=$(cat ./releases.json | grep "browser_download_url.*linux_amd64" | ...)

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.yaml already enabled trufflehog@3.90.6, but it runs:

trufflehog filesystem --json --fail --only-verified --no-update ${target}

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-git restores it:

trufflehog git --json --fail --only-verified --no-update file://. --since-commit ${upstream-ref}

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:

Scan Result
filesystem — what trufflehog already did ❌ missed it; reported only a pre-existing false positive
git --since-commit — what trufflehog-git adds PrivateKey ← probe-key.pem @ f48c6617

Also confirmed:

  • trunk check --filter=trufflehog-git runs clean on this branch in ~1.7s.
  • Config parses; actionlint and full trunk check pass on both modified files.
  • Workflow YAML parses; 13 jobs remain; nothing referenced the removed job via 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-verified and 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

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>
@jamesnrokt
jamesnrokt requested a review from a team as a code owner July 30, 2026 14:00
@cursor

cursor Bot commented Jul 30, 2026

Copy link
Copy Markdown

PR Summary

Low Risk
CI and lint configuration only; no application runtime, auth, or data-path changes.

Overview
Removes the standalone pr-check-hadcoded-secrets reusable workflow job from the PR workflow and moves git-history secret coverage into Trunk, which already runs on every PR via trunk-check.

Trunk now enables trufflehog-git@3.90.6 alongside the existing filesystem trufflehog scan, so commits introduced by the PR are scanned even when a secret was added and then deleted on the branch. Comments in .trunk/trunk.yaml document that behavior.

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.

@sonarqubecloud

Copy link
Copy Markdown

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>
@jamesnrokt jamesnrokt changed the title ci: remove hardcoded secrets check from PR workflow ci: replace flaky hardcoded-secrets job with trufflehog-git in Trunk Jul 30, 2026
Comment thread .trunk/trunk.yaml

@cursor cursor 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.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ 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.

Comment thread .github/workflows/pull-request.yml
@jamesnrokt
jamesnrokt merged commit 8511f40 into main Jul 30, 2026
41 checks passed
@jamesnrokt
jamesnrokt deleted the ci/remove-secrets-scan branch July 30, 2026 15:56
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