Skip to content

feat(trufflehog): centralize path exclusions and support .trufflehogignore#137

Merged
isaiah-grafana merged 1 commit intomainfrom
feature/trufflehog-global-excludes
Apr 7, 2026
Merged

feat(trufflehog): centralize path exclusions and support .trufflehogignore#137
isaiah-grafana merged 1 commit intomainfrom
feature/trufflehog-global-excludes

Conversation

@isaiah-grafana
Copy link
Copy Markdown
Contributor

@isaiah-grafana isaiah-grafana commented Mar 24, 2026

Adds configurable path exclusions to the TruffleHog scan so we stop flagging hashes in lock files, vendor code, and other known false-positive paths.

How it works

  • Org-wide exclusions (trufflehog/exclude-paths.txt) — default patterns that apply to every repo (vendor/, lock files, dependency manifests, grafana dashboards). Managed centrally here, fetched at runtime.
  • Per-repo exclusions (.trufflehogignore) — any repo can add a .trufflehogignore to its root with Go regex patterns for repo-specific paths. Gets merged with the org-wide list automatically.

How to use

  • Org-wide: add a regex to trufflehog/exclude-paths.txt, merge to main.
  • Repo-specific: add a .trufflehogignore file to the repo root.

Other fixes

  • Moved ${{ }} expressions out of run: blocks into env: blocks (code injection fix)

  • Simplified scan loop with a grep pre-filter instead of per-file case statements

  • Fixed jq CHANGELOG filter with try/catch

Testing

Tested on cloud-traces-operators #194 — confirmed exclusions load correctly and files are skipped as expected.

Comment thread .github/workflows/reusable-trufflehog.yml Fixed
Comment thread .github/workflows/reusable-trufflehog.yml Fixed
@isaiah-grafana isaiah-grafana force-pushed the feature/trufflehog-global-excludes branch from 585248a to bfdeb21 Compare April 7, 2026 04:15
@isaiah-grafana isaiah-grafana changed the title feat(trufflehog): global exclude file, vendor skip, org wrapper comments feat(trufflehog): add org-wide path exclusions via exclude-paths.txt Apr 7, 2026
@isaiah-grafana isaiah-grafana force-pushed the feature/trufflehog-global-excludes branch 2 times, most recently from bb77eae to 52c2c14 Compare April 7, 2026 04:23
@isaiah-grafana isaiah-grafana reopened this Apr 7, 2026
@isaiah-grafana isaiah-grafana force-pushed the feature/trufflehog-global-excludes branch 2 times, most recently from 68280bd to abf5eaa Compare April 7, 2026 04:34
@isaiah-grafana isaiah-grafana changed the title feat(trufflehog): add org-wide path exclusions via exclude-paths.txt feat(trufflehog): centralize path exclusions in exclude-paths.txt Apr 7, 2026
@isaiah-grafana isaiah-grafana marked this pull request as ready for review April 7, 2026 04:35
@isaiah-grafana isaiah-grafana requested a review from a team as a code owner April 7, 2026 04:35
@isaiah-grafana isaiah-grafana force-pushed the feature/trufflehog-global-excludes branch 2 times, most recently from 17bed03 to 11a03b8 Compare April 7, 2026 04:39
@isaiah-grafana isaiah-grafana requested review from aliceatgrafana and dannyc-grafana and removed request for jamesc-grafana April 7, 2026 04:46
@isaiah-grafana isaiah-grafana force-pushed the feature/trufflehog-global-excludes branch from 11a03b8 to f6da1c6 Compare April 7, 2026 13:18
@isaiah-grafana isaiah-grafana changed the title feat(trufflehog): centralize path exclusions in exclude-paths.txt feat(trufflehog): centralize path exclusions and support .trufflehogignore Apr 7, 2026
…gnore

Add a centralized `trufflehog/exclude-paths.txt` for org-wide default
exclusions (vendor/, lock files, manifests, grafana.json, dashboards)
and support repo-local `.trufflehogignore` files for per-repo overrides.

Changes:
- Add trufflehog/exclude-paths.txt fetched at runtime from this repo
  (GitHub API → raw fallback → workflow ref fallback)
- Append repo-local .trufflehogignore to exclude patterns if present
- Simplify PR/merge-group scan loop with grep pre-filter
- Move ${{ }} expressions from run blocks into env blocks
- Fix jq CHANGELOG filter to use try/catch syntax
- Clean up org-required-trufflehog.yml comments
@isaiah-grafana isaiah-grafana force-pushed the feature/trufflehog-global-excludes branch 2 times, most recently from d2d989c to afe3717 Compare April 7, 2026 13:38
@isaiah-grafana isaiah-grafana requested a review from Proximyst April 7, 2026 13:51
Copy link
Copy Markdown
Contributor

@ezebunandu ezebunandu left a comment

Choose a reason for hiding this comment

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

It looks like the workflow will accept a trufflehog exclusion from the PR head, allowing a contributor to exclude files that should otherwise be scanned.

Would accepting the trufflehog exclusion from only the main branch not be a better approach?

@isaiah-grafana
Copy link
Copy Markdown
Contributor Author

It looks like the workflow will accept a trufflehog exclusion from the PR head, allowing a contributor to exclude files that should otherwise be scanned.

Would accepting the trufflehog exclusion from only the main branch not be a better approach?

Good point. I thought about this too. The .trufflehogignore is read from the checked-out tree, so technically a contributor could add it in the same PR to skip scanning on certain paths. But in practice, the change to .trufflehogignore would show up in the PR diff, so reviewers would see it. It's also the same trust model as the inline trufflehog:ignore comment, which already works from the PR head.

We could read it from the default branch instead, but that adds friction for the legitimate use cases. Teams would have to merge the ignore file first before it takes effect. Since this is mostly catching accidental commits from internal contributors, I think reading from the working tree is a reasonable here

Copy link
Copy Markdown
Contributor

@ezebunandu ezebunandu left a comment

Choose a reason for hiding this comment

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

LGTM.

@isaiah-grafana isaiah-grafana merged commit 22ec812 into main Apr 7, 2026
13 checks passed
@isaiah-grafana isaiah-grafana deleted the feature/trufflehog-global-excludes branch April 7, 2026 14:44
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.

3 participants