|
1 | 1 | # SPDX-License-Identifier: MPL-2.0 |
2 | | -# Prevention workflow - scans for hardcoded secrets before they reach main |
3 | 2 | name: Secret Scanner |
4 | 3 |
|
5 | 4 | on: |
6 | 5 | pull_request: |
7 | 6 | push: |
8 | 7 | branches: [main] |
9 | 8 |
|
| 9 | +concurrency: |
| 10 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 11 | + cancel-in-progress: true |
| 12 | + |
10 | 13 | permissions: |
11 | 14 | contents: read |
12 | 15 |
|
13 | 16 | jobs: |
14 | | - trufflehog: |
15 | | - runs-on: ubuntu-latest |
16 | | - steps: |
17 | | - - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
18 | | - with: |
19 | | - fetch-depth: 0 # Full history for scanning |
20 | | - |
21 | | - - name: TruffleHog Secret Scan |
22 | | - uses: trufflesecurity/trufflehog@6c05c4a00b91aa542267d8e32a8254774799d68d # v3 |
23 | | - with: |
24 | | - extra_args: --only-verified --fail |
25 | | - |
26 | | - gitleaks: |
27 | | - runs-on: ubuntu-latest |
28 | | - steps: |
29 | | - - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
30 | | - with: |
31 | | - fetch-depth: 0 |
32 | | - |
33 | | - - name: Gitleaks Secret Scan |
34 | | - uses: gitleaks/gitleaks-action@ff98106e4c7b2bc287b24eaf42907196329070c7 # v2 |
35 | | - env: |
36 | | - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
37 | | - |
38 | | - # Rust-specific: Check for hardcoded crypto values |
39 | | - rust-secrets: |
40 | | - runs-on: ubuntu-latest |
41 | | - if: hashFiles('**/Cargo.toml') != '' |
42 | | - steps: |
43 | | - - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
44 | | - |
45 | | - - name: Check for hardcoded secrets in Rust |
46 | | - run: | |
47 | | - # Patterns that suggest hardcoded secrets |
48 | | - PATTERNS=( |
49 | | - 'const.*SECRET.*=.*"' |
50 | | - 'const.*KEY.*=.*"[a-zA-Z0-9]{16,}"' |
51 | | - 'const.*TOKEN.*=.*"' |
52 | | - 'let.*api_key.*=.*"' |
53 | | - 'HMAC.*"[a-fA-F0-9]{32,}"' |
54 | | - 'password.*=.*"[^"]+"' |
55 | | - ) |
56 | | -
|
57 | | - found=0 |
58 | | - for pattern in "${PATTERNS[@]}"; do |
59 | | - if grep -rn --include="*.rs" -E "$pattern" src/; then |
60 | | - echo "WARNING: Potential hardcoded secret found matching: $pattern" |
61 | | - found=1 |
62 | | - fi |
63 | | - done |
64 | | -
|
65 | | - if [ $found -eq 1 ]; then |
66 | | - echo "::error::Potential hardcoded secrets detected. Use environment variables instead." |
67 | | - exit 1 |
68 | | - fi |
| 17 | + scan: |
| 18 | + uses: hyperpolymath/standards/.github/workflows/secret-scanner-reusable.yml@3e4bd4c93911750727e2e4c66dff859e00079da0 |
| 19 | + secrets: inherit |
0 commit comments