Skip to content

Commit 9926492

Browse files
authored
ci(repo): add gitleaks secret scanning CI gate (#216)
* chore: add gitleaks secret scanning CI gate Adds a PR-gate + scheduled full-history gitleaks scan. No .gitleaks.toml needed: a full-history scan of this repo came back clean (zero findings), so no allowlist tuning required. * fix: pin gitleaks version instead of resolving latest dynamically The dynamic lookup (curl api.github.com/.../releases/latest, unauthenticated) got rate-limited on the runner's shared IP, silently emptied $VERSION, and tripped `set -e` before printing anything -- reproduced the failure mode locally. Pinning avoids the extra network call/rate-limit risk entirely and makes the install step reproducible. Also adds `set -euo pipefail` and `-f` on curl so any future failure here is loud instead of silent. * harden: least-privilege permissions, concurrency, checksum-verified install Addresses review feedback (Copilot on raiko2#147, Claude bot on alethia-reth#216), verified empirically before applying: - Add explicit `permissions: contents: read` and a `concurrency` group so runs don't pile up on rapid pushes. - `persist-credentials: false` on checkout -- this job never needs to push. - Verify the downloaded gitleaks binary against its published SHA256 before executing it, instead of trusting an unauthenticated curl download. Did NOT apply two other review suggestions after testing them directly: - DeepSeek (taiko-mono#21923) claimed `[allowlist].paths` needs gitignore-glob syntax, not regex. Tested locally: a glob pattern crashes gitleaks (`regexp: Compile(...): missing argument to repetition operator`). The existing regex syntax is correct. - Claude bot (alethia-reth#216) flagged `--log-opts="BASE..HEAD"` as potentially broken. Tested locally with a real commit range: it correctly scans exactly the PR's commits, nothing more/less. No change needed. - Copilot also claimed this repo already pins actions to a commit SHA and uses persist-credentials elsewhere -- checked, neither is actually true here, so not introducing an inconsistent one-off pinning convention.
1 parent 2bc92e6 commit 9926492

1 file changed

Lines changed: 46 additions & 0 deletions

File tree

.github/workflows/secret-scan.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: "Secret Scan"
2+
3+
on:
4+
pull_request:
5+
types: [opened, synchronize, reopened]
6+
push:
7+
branches: [main]
8+
schedule:
9+
- cron: "0 6 * * 1" # weekly full-history scan, Monday 06:00 UTC
10+
11+
permissions:
12+
contents: read
13+
14+
concurrency:
15+
group: secret-scan-${{ github.workflow }}-${{ github.ref }}
16+
cancel-in-progress: true
17+
18+
jobs:
19+
gitleaks:
20+
name: gitleaks
21+
runs-on: ubuntu-latest
22+
steps:
23+
- uses: actions/checkout@v4
24+
with:
25+
fetch-depth: 0
26+
persist-credentials: false
27+
28+
- name: Install gitleaks
29+
env:
30+
GITLEAKS_VERSION: "8.30.1"
31+
GITLEAKS_SHA256: "551f6fc83ea457d62a0d98237cbad105af8d557003051f41f3e7ca7b3f2470eb"
32+
run: |
33+
set -euo pipefail
34+
curl -fsSL "https://github.com/gitleaks/gitleaks/releases/download/v${GITLEAKS_VERSION}/gitleaks_${GITLEAKS_VERSION}_linux_x64.tar.gz" -o gitleaks.tar.gz
35+
echo "${GITLEAKS_SHA256} gitleaks.tar.gz" | sha256sum -c -
36+
tar -xzf gitleaks.tar.gz gitleaks
37+
sudo mv gitleaks /usr/local/bin/gitleaks
38+
gitleaks version
39+
40+
- name: Scan PR diff
41+
if: github.event_name == 'pull_request'
42+
run: gitleaks detect --source . --log-opts="${{ github.event.pull_request.base.sha }}..${{ github.event.pull_request.head.sha }}" --redact --verbose
43+
44+
- name: Scan full history
45+
if: github.event_name != 'pull_request'
46+
run: gitleaks detect --source . --redact --verbose

0 commit comments

Comments
 (0)