File tree Expand file tree Collapse file tree 1 file changed +67
-0
lines changed
Expand file tree Collapse file tree 1 file changed +67
-0
lines changed Original file line number Diff line number Diff line change 1+ # SPDX-License-Identifier: AGPL-3.0-or-later
2+ # Prevention workflow - scans for hardcoded secrets before they reach main
3+ name : Secret Scanner
4+
5+ on :
6+ pull_request :
7+ push :
8+ branches : [main]
9+
10+ permissions : read-all
11+
12+ jobs :
13+ trufflehog :
14+ runs-on : ubuntu-latest
15+ steps :
16+ - uses : actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
17+ with :
18+ fetch-depth : 0 # Full history for scanning
19+
20+ - name : TruffleHog Secret Scan
21+ uses : trufflesecurity/trufflehog@8a8ef8526528d8a4ff3e2c90be08e25ef8efbd9b # v3
22+ with :
23+ extra_args : --only-verified --fail
24+
25+ gitleaks :
26+ runs-on : ubuntu-latest
27+ steps :
28+ - uses : actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
29+ with :
30+ fetch-depth : 0
31+
32+ - name : Gitleaks Secret Scan
33+ uses : gitleaks/gitleaks-action@ff98106e4c7b2bc287b24eaf42907196329070c7 # v2
34+ env :
35+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
36+
37+ # Rust-specific: Check for hardcoded crypto values
38+ rust-secrets :
39+ runs-on : ubuntu-latest
40+ if : hashFiles('**/Cargo.toml') != ''
41+ steps :
42+ - uses : actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
43+
44+ - name : Check for hardcoded secrets in Rust
45+ run : |
46+ # Patterns that suggest hardcoded secrets
47+ PATTERNS=(
48+ 'const.*SECRET.*=.*"'
49+ 'const.*KEY.*=.*"[a-zA-Z0-9]{16,}"'
50+ 'const.*TOKEN.*=.*"'
51+ 'let.*api_key.*=.*"'
52+ 'HMAC.*"[a-fA-F0-9]{32,}"'
53+ 'password.*=.*"[^"]+"'
54+ )
55+
56+ found=0
57+ for pattern in "${PATTERNS[@]}"; do
58+ if grep -rn --include="*.rs" -E "$pattern" src/; then
59+ echo "WARNING: Potential hardcoded secret found matching: $pattern"
60+ found=1
61+ fi
62+ done
63+
64+ if [ $found -eq 1 ]; then
65+ echo "::error::Potential hardcoded secrets detected. Use environment variables instead."
66+ exit 1
67+ fi
You can’t perform that action at this time.
0 commit comments