|
55 | 55 | sudo chmod +x /usr/local/bin/trufflehog |
56 | 56 | trufflehog --version |
57 | 57 |
|
| 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 | +
|
58 | 82 | - name: Scan for secrets |
59 | 83 | id: scan |
60 | 84 | run: | |
|
68 | 92 |
|
69 | 93 | if [[ -s changed-files.txt ]]; then |
70 | 94 | 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 | +
|
71 | 106 | if [[ -f "${file}" ]]; then |
72 | 107 | 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 |
74 | 109 | fi |
75 | 110 | done < changed-files.txt |
76 | 111 | else |
|
79 | 114 | else |
80 | 115 | # Push to main: Scan current filesystem |
81 | 116 | 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 |
83 | 118 | fi |
84 | 119 |
|
85 | 120 | # Process results |
|
0 commit comments