Skip to content

Commit 08e2d24

Browse files
hyperpolymathclaude
andcommitted
ci(secret-scanner): make gitleaks gate for real, not continue-on-error
The gitleaks job carried continue-on-error: true (comment: gitleaks-action tool-cache PATH injection unreliable on self-hosted runners), so the estate's primary secret scanner could not fail a single PR anywhere it is used. Replace gitleaks/gitleaks-action with a pinned, checksum-verified gitleaks 8.18.4 binary run directly (gitleaks detect --source . --no-git --exit-code 1). A direct install is deterministic on every runner, removing the exact unreliability the continue-on-error was papering over, so the scan now gates. Comments/summary were already disabled via env vars, so the action provided only the scan; the swap loses no functionality and drops the now-unneeded GITHUB_TOKEN env and fetch-depth: 0. Verified locally with the pinned binary: checksum matches; a private-key fixture exits 1, a clean tree exits 0; actionlint clean. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 5fc40aa commit 08e2d24

1 file changed

Lines changed: 33 additions & 11 deletions

File tree

.github/workflows/secret-scanner-reusable.yml

Lines changed: 33 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -85,20 +85,42 @@ jobs:
8585
# `contents: read`, which they get from the workflow-level block.
8686
permissions:
8787
contents: read
88-
# gitleaks-action's `ScanPullRequest` posts a summary comment via
89-
# the GitHub Issues/PR API. We disabled it via env vars below.
9088
steps:
9189
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
92-
with:
93-
fetch-depth: 0
9490

95-
- name: Gitleaks Secret Scan
96-
continue-on-error: true # gitleaks-action tool-cache PATH injection unreliable on self-hosted runners
97-
uses: gitleaks/gitleaks-action@e0c47f4f8be36e29cdc102c57e68cb5cbf0e8d1e # v3.0.0
98-
env:
99-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
100-
GITLEAKS_ENABLE_COMMENTS: false
101-
GITLEAKS_ENABLE_SUMMARY: false
91+
# Gitleaks runs as a pinned, checksum-verified binary rather than via
92+
# gitleaks/gitleaks-action. The action injects gitleaks into the runner
93+
# tool-cache and prepends it to PATH, which is unreliable on self-hosted
94+
# runners — that unreliability was the reason this step previously carried
95+
# `continue-on-error: true`, i.e. the estate's primary secret scanner
96+
# could not fail a PR. A pinned direct install is deterministic on every
97+
# runner, so the scan gates for real.
98+
- name: Install gitleaks (pinned + checksum-verified)
99+
run: |
100+
set -euo pipefail
101+
GITLEAKS_VERSION=8.18.4
102+
SHA256=ba6dbb656933921c775ee5a2d1c13a91046e7952e9d919f9bac4cec61d628e7d
103+
cd "$RUNNER_TEMP"
104+
curl -fsSL -o gitleaks.tar.gz \
105+
"https://github.com/gitleaks/gitleaks/releases/download/v${GITLEAKS_VERSION}/gitleaks_${GITLEAKS_VERSION}_linux_x64.tar.gz"
106+
echo "${SHA256} gitleaks.tar.gz" | sha256sum -c -
107+
tar -xzf gitleaks.tar.gz gitleaks
108+
chmod +x gitleaks
109+
./gitleaks version
110+
111+
# Scans the checked-out working tree (--no-git): deterministic and fast.
112+
# A finding exits non-zero and fails the check. Full-history scanning is
113+
# available by removing --no-git and adding `fetch-depth: 0` to the
114+
# checkout above, at the cost of a slower scan on every PR.
115+
- name: Gitleaks secret scan (gating)
116+
run: |
117+
set -euo pipefail
118+
"$RUNNER_TEMP/gitleaks" detect \
119+
--source . \
120+
--no-git \
121+
--redact \
122+
--no-banner \
123+
--exit-code 1
102124
103125
# Rust-specific: hardcoded crypto values. Self-skips when no Cargo.toml
104126
# is present, so this job is safe to run on non-Rust repos.

0 commit comments

Comments
 (0)