Skip to content

Commit f930a43

Browse files
feat: add global TruffleHog exclusions (#104)
Use TruffleHog's native --exclude-paths flag to exclude common false positives: - go.sum, go.mod (Go checksums) - package-lock.json, yarn.lock, pnpm-lock.yaml (Node.js) - poetry.lock, Pipfile.lock, uv.lock (Python) - Cargo.lock (Rust) - Gemfile.lock (Ruby) Benefits: - Centrally managed in security-github-actions workflow - Uses TruffleHog's native exclusion mechanism - No per-repo configuration needed - Addresses developer feedback about false positives in lock files
1 parent 00b4cb4 commit f930a43

File tree

1 file changed

+37
-2
lines changed

1 file changed

+37
-2
lines changed

.github/workflows/reusable-trufflehog.yml

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,30 @@ jobs:
5555
sudo chmod +x /usr/local/bin/trufflehog
5656
trufflehog --version
5757
58+
- name: Create global exclusions
59+
run: |
60+
# Create centralized exclusion patterns for common false positives
61+
cat > /tmp/trufflehog-exclude.txt <<'EOF'
62+
# Lock files and checksums (contain hashes, not secrets)
63+
path:go\.sum$
64+
path:go\.mod$
65+
# Dependency manifests (contain URLs that trigger false positives)
66+
path:package\.json$
67+
path:package-lock\.json$
68+
path:pnpm-lock\.yaml$
69+
path:yarn\.lock$
70+
path:poetry\.lock$
71+
path:Pipfile\.lock$
72+
path:uv\.lock$
73+
path:Cargo\.lock$
74+
path:Gemfile\.lock$
75+
# Grafana plugin metadata
76+
path:grafana\.json$
77+
EOF
78+
79+
echo "Created global exclusion patterns:"
80+
cat /tmp/trufflehog-exclude.txt
81+
5882
- name: Scan for secrets
5983
id: scan
6084
run: |
@@ -68,9 +92,20 @@ jobs:
6892
6993
if [[ -s changed-files.txt ]]; then
7094
while IFS= read -r file; do
95+
# Get just the filename
96+
filename=$(basename "$file")
97+
98+
# Skip excluded files (use case statement for cleaner matching)
99+
case "$filename" in
100+
go.sum|go.mod|package.json|package-lock.json|pnpm-lock.yaml|yarn.lock|poetry.lock|Pipfile.lock|uv.lock|Cargo.lock|Gemfile.lock|grafana.json)
101+
echo "Skipping: ${file} (excluded manifest/lock file)"
102+
continue
103+
;;
104+
esac
105+
71106
if [[ -f "${file}" ]]; then
72107
echo "Scanning: ${file}"
73-
trufflehog filesystem "${file}" --json --no-update --results=verified,unverified >> results.ndjson || true
108+
trufflehog filesystem "${file}" --exclude-paths /tmp/trufflehog-exclude.txt --json --no-update --results=verified,unverified >> results.ndjson || true
74109
fi
75110
done < changed-files.txt
76111
else
@@ -79,7 +114,7 @@ jobs:
79114
else
80115
# Push to main: Scan current filesystem
81116
echo "Scanning current filesystem..."
82-
trufflehog filesystem . --json --no-update --results=verified,unverified > results.ndjson || true
117+
trufflehog filesystem . --exclude-paths /tmp/trufflehog-exclude.txt --json --no-update --results=verified,unverified > results.ndjson || true
83118
fi
84119
85120
# Process results

0 commit comments

Comments
 (0)