|
20 | 20 | - name: TruffleHog OSS Secret Scanning |
21 | 21 | uses: trufflesecurity/trufflehog@main |
22 | 22 | with: |
23 | | - # Scan the entire repository |
| 23 | + # Scan the entire repository |
24 | 24 | path: ./ |
25 | | - # Only show verified secrets and unknown (high confidence) |
| 25 | + # Only show verified secrets and unknown (high confidence) |
26 | 26 | extra_args: --results=verified,unknown |
27 | 27 |
|
28 | 28 | - name: Setup Python for detect-secrets |
|
79 | 79 |
|
80 | 80 | echo "✅ Custom secret checks passed!" |
81 | 81 |
|
| 82 | + # ---- Gitleaks CLI pinned to 8.28.0 (no SARIF) ---- |
| 83 | + - name: Download Gitleaks v8.28.0 (linux_x64) + verify checksum |
| 84 | + env: |
| 85 | + GITLEAKS_VERSION: "8.28.0" |
| 86 | + run: | |
| 87 | + set -euo pipefail |
| 88 | + TAR="gitleaks_${GITLEAKS_VERSION}_linux_x64.tar.gz" |
| 89 | + BASE="https://github.com/gitleaks/gitleaks/releases/download/v${GITLEAKS_VERSION}" |
| 90 | + curl -sSL "${BASE}/${TAR}" -o gitleaks.tar.gz |
| 91 | + curl -sSL "${BASE}/gitleaks_${GITLEAKS_VERSION}_checksums.txt" -o checksums.txt |
| 92 | + EXPECTED=$(grep "$TAR" checksums.txt | awk '{print $1}') |
| 93 | + ACTUAL=$(sha256sum gitleaks.tar.gz | awk '{print $1}') |
| 94 | + [ "$EXPECTED" = "$ACTUAL" ] || { echo "Checksum mismatch!"; exit 1; } |
| 95 | + tar -xzf gitleaks.tar.gz gitleaks |
| 96 | + chmod +x gitleaks |
| 97 | + ./gitleaks version |
| 98 | +
|
| 99 | + # PRs: stage only changed files and scan staged diff (blocks on new leaks) |
| 100 | + - name: Run Gitleaks on staged PR changes (blocking) |
| 101 | + if: ${{ github.event_name == 'pull_request' }} |
| 102 | + run: | |
| 103 | + set -euo pipefail |
| 104 | + # Ensure base is present and compute changed files |
| 105 | + git fetch --no-tags --prune --depth=1 origin +refs/heads/${{ github.base_ref }}:refs/remotes/origin/${{ github.base_ref }} |
| 106 | + git diff --name-only origin/${{ github.base_ref }}..HEAD > /tmp/changed_files.txt |
| 107 | + if [ -s /tmp/changed_files.txt ]; then |
| 108 | + xargs -a /tmp/changed_files.txt git add |
| 109 | + ./gitleaks protect --staged --no-banner --redact --config-path .gitleaks.toml |
| 110 | + xargs -a /tmp/changed_files.txt git reset |
| 111 | + else |
| 112 | + echo "No changed files; skipping." |
| 113 | + fi |
| 114 | +
|
| 115 | + # Non-PR runs (e.g., merge_group/push): full scan, do not fail the job |
| 116 | + - name: Run Gitleaks full scan (non-blocking) |
| 117 | + if: ${{ github.event_name != 'pull_request' }} |
| 118 | + run: | |
| 119 | + ./gitleaks detect --source . --no-banner --redact --config-path .gitleaks.toml || true |
| 120 | +
|
82 | 121 | # Optional: Add Semgrep for additional security analysis |
83 | 122 | semgrep: |
84 | 123 | runs-on: ubuntu-latest |
|
92 | 131 | - name: Run Semgrep |
93 | 132 | uses: returntocorp/semgrep-action@v1 |
94 | 133 | with: |
95 | | - # Run security-focused rules |
| 134 | + # Run security-focused rules |
96 | 135 | config: >- |
97 | 136 | p/security-audit |
98 | 137 | p/secrets |
|
0 commit comments