Skip to content

Commit c852818

Browse files
chore(trufflehog): update-excludes.sh + clearer prefixes.txt how-to
Made-with: Cursor
1 parent 17877a0 commit c852818

5 files changed

Lines changed: 21 additions & 20 deletions

File tree

.github/workflows/reusable-trufflehog.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,7 @@ jobs:
5757
DEST=/tmp/trufflehog-exclude.txt
5858
REPO=grafana/security-github-actions
5959
REF=main
60-
# Prefer trufflehog/global-exclude.txt on main. To change rules: edit trufflehog/prefixes.txt
61-
# and/or trufflehog/build_exclude_file.py, then: python3 trufflehog/build_exclude_file.py > trufflehog/global-exclude.txt
60+
# Exclusions: edit trufflehog/prefixes.txt, run ./trufflehog/update-excludes.sh, commit prefixes + global-exclude.txt
6261
RAW_BASE="https://raw.githubusercontent.com/grafana/security-github-actions/${REF}/trufflehog"
6362
RAW_URL="${RAW_BASE}/global-exclude.txt"
6463
RAW_BUILD="${RAW_BASE}/build_exclude_file.py"
@@ -84,8 +83,7 @@ jobs:
8483
echo "::warning::Could not fetch or rebuild TruffleHog excludes from ${REPO}@${REF}. Using last-resort bundled file — merge to main or fix token access."
8584
# Last resort only: must match stdout of python3 trufflehog/build_exclude_file.py (same commit).
8685
cat > "${DEST}" <<'EOF'
87-
# Generated by trufflehog/build_exclude_file.py + trufflehog/prefixes.txt — do not edit by hand.
88-
# Regenerate: python3 trufflehog/build_exclude_file.py > trufflehog/global-exclude.txt
86+
# Generated — do not edit by hand. Edit trufflehog/prefixes.txt then run ./trufflehog/update-excludes.sh
8987
#
9088
# --- directory prefixes (from prefixes.txt) ---
9189
# prefix: vendor

trufflehog/build_exclude_file.py

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,5 @@
11
#!/usr/bin/env python3
2-
"""
3-
Emit TruffleHog --exclude-paths file content to stdout.
4-
5-
Edit trufflehog/prefixes.txt, then:
6-
python3 trufflehog/build_exclude_file.py > trufflehog/global-exclude.txt
7-
8-
If you change STATIC_PATTERNS or prefix rules, refresh the last-resort heredoc in
9-
.github/workflows/reusable-trufflehog.yml to match this script's stdout (or rely on
10-
fetch / rebuild-from-prefixes paths in CI).
11-
"""
2+
"""Build TruffleHog exclude file. Prefer: ./trufflehog/update-excludes.sh from repo root."""
123

134
from __future__ import annotations
145

@@ -53,8 +44,7 @@ def main() -> None:
5344

5445
lines: list[str] = []
5546
lines.append(
56-
"# Generated by trufflehog/build_exclude_file.py + trufflehog/prefixes.txt — do not edit by hand.\n"
57-
"# Regenerate: python3 trufflehog/build_exclude_file.py > trufflehog/global-exclude.txt\n"
47+
"# Generated — do not edit by hand. Edit trufflehog/prefixes.txt then run ./trufflehog/update-excludes.sh\n"
5848
"#\n"
5949
)
6050

trufflehog/global-exclude.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
# Generated by trufflehog/build_exclude_file.py + trufflehog/prefixes.txt — do not edit by hand.
2-
# Regenerate: python3 trufflehog/build_exclude_file.py > trufflehog/global-exclude.txt
1+
# Generated — do not edit by hand. Edit trufflehog/prefixes.txt then run ./trufflehog/update-excludes.sh
32
#
43
# --- directory prefixes (from prefixes.txt) ---
54
# prefix: vendor

trufflehog/prefixes.txt

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
1-
# One repo-relative directory prefix per line (forward slashes). No regex.
2-
# Regenerate: python3 trufflehog/build_exclude_file.py > trufflehog/global-exclude.txt
1+
# How to add a directory exclusion (no regex — one path per line):
2+
#
3+
# 1. Add a line below (repo-relative path, use /), e.g. docs/imported
4+
# 2. From the repo root, run: ./trufflehog/update-excludes.sh
5+
# 3. Commit and push BOTH:
6+
# trufflehog/prefixes.txt
7+
# trufflehog/global-exclude.txt
8+
# 4. Merge to main — consumer repos pick it up automatically.
9+
#
10+
# Lockfiles (go.sum, package.json, …) are listed in trufflehog/build_exclude_file.py if you need to change those.
311

412
vendor
513
content/grafana/dashboards

trufflehog/update-excludes.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/usr/bin/env bash
2+
# Regenerates trufflehog/global-exclude.txt from prefixes.txt + build_exclude_file.py
3+
set -euo pipefail
4+
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
5+
python3 "${ROOT}/trufflehog/build_exclude_file.py" > "${ROOT}/trufflehog/global-exclude.txt"
6+
echo "Wrote ${ROOT}/trufflehog/global-exclude.txt"

0 commit comments

Comments
 (0)