|
1 | 1 | #!/bin/bash |
2 | 2 | # check-shipping-leaks.sh — fast pre-merge leak scanner for public-shipping files. |
3 | 3 | # |
4 | | -# Unlike scripts/scrub-check.sh (which scans an entire public-tree clone), |
5 | | -# this scans only the files that would ship publicly, in the dev repo, on |
| 4 | +# This scans only the files that would ship publicly, in the dev repo, on |
6 | 5 | # the current branch. Designed for speed: run as a pre-commit hook or in |
7 | 6 | # CI on every PR. |
8 | 7 | # |
|
20 | 19 | set -euo pipefail |
21 | 20 |
|
22 | 21 | # Patterns that must NEVER appear in public-shipping files. |
23 | | -# Synced with scripts/scrub-check.sh and SYNC-PUBLIC.md. |
| 22 | +# Synced with SYNC-PUBLIC.md. |
24 | 23 | PATTERNS=( |
25 | 24 | # Private IPs and infrastructure |
26 | 25 | '10\.2\.1\.(61|65|69)' |
@@ -113,10 +112,14 @@ DEV_ONLY_PREFIXES=( |
113 | 112 | '.github/PULL_REQUEST_TEMPLATE.md' |
114 | 113 | ) |
115 | 114 |
|
| 115 | +# Public repo paths that must never be tracked at all. |
| 116 | +FORBIDDEN_PUBLIC_PATHS=( |
| 117 | + 'scripts/scrub-check.sh' |
| 118 | +) |
| 119 | + |
116 | 120 | # Files that intentionally contain the blocked patterns as scanner inputs. |
117 | 121 | # Skip them so the scanner does not flag its own source data. |
118 | 122 | SCANNER_SOURCES=( |
119 | | - 'scripts/scrub-check.sh' |
120 | 123 | 'scripts/check-shipping-leaks.sh' |
121 | 124 | # Tests may enumerate forbidden patterns as part of the guard itself. |
122 | 125 | 'tests/test_deploy_systemd.py' |
@@ -160,6 +163,16 @@ if [ "${#FILES[@]}" -eq 0 ]; then |
160 | 163 | exit 0 |
161 | 164 | fi |
162 | 165 |
|
| 166 | +for f in "${FILES[@]}"; do |
| 167 | + normalized="${f#./}" |
| 168 | + for forbidden in "${FORBIDDEN_PUBLIC_PATHS[@]}"; do |
| 169 | + if [ "$normalized" = "$forbidden" ]; then |
| 170 | + echo "FORBIDDEN PATH — $forbidden is tracked in the public tree." |
| 171 | + exit 1 |
| 172 | + fi |
| 173 | + done |
| 174 | +done |
| 175 | + |
163 | 176 | # ── Filter to public-shipping files ─────────────────────────────────────────── |
164 | 177 |
|
165 | 178 | is_dev_only() { |
|
0 commit comments