Skip to content

ci(gitleaks): gate PRs on their own commits, pin two more false positives - #168

Merged
ralyodio merged 1 commit into
masterfrom
fix/gitleaks-pr-scope
Jul 30, 2026
Merged

ralyodio merged 1 commit into
masterfrom
fix/gitleaks-pr-scope

Conversation

@ralyodio

Copy link
Copy Markdown
Contributor

Every PR in this repo fails gitleaks, whatever it touches — #163 (an /ads feature) and #166 (the env-backup removal) both went red on a finding neither introduced.

Cause

The job runs gitleaks detect --source . with fetch-depth: 0, i.e. full history, on every PR. History does not change when a PR changes, so the same blob is reported forever. A check that is red on arrival is a check nobody reads — which is the failure mode that actually matters for a secret scanner.

Change

PRs scan base..head only. History is still scanned in full on push to master and on the existing weekly cron, so an existing finding cannot be merged out of sight — it just stops masking new ones.

Two more false-positive fingerprints. A fingerprint pins one commit, and both lines already in .gitleaksignore survived later edits to their files, so each matches again under a newer SHA:

  • 2eb14f9b — the pk_test_… publishable key in the sample <script> fixture the analyzer test asserts on
  • 508859ed — the docs curl example, by then reading -H "Authorization: Bearer $SECRET", a shell variable

Deliberately NOT suppressed

The 21 findings in .env.bak-2026-07-28 (commit 925da5e2) — a private key, a GCP API key and 19 API keys. Those are real credentials, still in history. Pinning them before they are rotated would hide a live exposure. The full-history scan stays red on them until they are rotated and the blob is purged, which is correct.

Verification

Run locally with gitleaks 8.21.2, the same version CI installs:

  • Full-history scan: 23 → 21 findings; the 2 non-env findings are gone, all 21 left are the real .env.bak credentials.
  • PR-mode scan of this branch: 1 commits scanned … no leaks found, exit 0.
  • The gate still blocks new secrets — planted a private key in a temp commit, PR-mode scan reported leaks found: 1, exit 1. (First attempt used AKIAIOSFODNN7EXAMPLE, which gitleaks allowlists as AWS's own documentation key, so it correctly did not fire.)

🤖 Generated with Claude Code

…ives

Every PR in this repo failed gitleaks, whatever it touched. The job ran
`gitleaks detect --source .` over full history, so it resolved to a blob
committed once and reported it forever — #163 and #166 both went red on a
finding neither introduced. A check that is red on arrival stops being read,
which is the failure mode that matters here.

Pull requests now scan only base..head. History is still scanned in full on
push to master and on the weekly cron, so an existing finding cannot be merged
out of sight — it just stops masking new ones.

Two more false-positive fingerprints. A fingerprint pins one commit, and both
already-pinned lines survived later edits to their files, so each matched again
under a newer SHA: the pk_test_ fixture the analyzer test asserts on, and the
docs curl example that by then read `-H "Authorization: Bearer $SECRET"`.

Deliberately still unpinned: the 21 findings in .env.bak-2026-07-28. Those are
real credentials, they remain in history, and suppressing them before they are
rotated would hide a live exposure.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

vu1nz Security Review

0 finding(s) in PR #?

No security issues found.

@ralyodio
ralyodio merged commit e3d0f63 into master Jul 30, 2026
8 checks passed
@ralyodio
ralyodio deleted the fix/gitleaks-pr-scope branch July 30, 2026 21:58
ralyodio added a commit that referenced this pull request Jul 30, 2026
…ives (#168)

Every PR in this repo failed gitleaks, whatever it touched. The job ran
`gitleaks detect --source .` over full history, so it resolved to a blob
committed once and reported it forever — #163 and #166 both went red on a
finding neither introduced. A check that is red on arrival stops being read,
which is the failure mode that matters here.

Pull requests now scan only base..head. History is still scanned in full on
push to master and on the weekly cron, so an existing finding cannot be merged
out of sight — it just stops masking new ones.

Two more false-positive fingerprints. A fingerprint pins one commit, and both
already-pinned lines survived later edits to their files, so each matched again
under a newer SHA: the pk_test_ fixture the analyzer test asserts on, and the
docs curl example that by then read `-H "Authorization: Bearer $SECRET"`.

Deliberately still unpinned: the 21 findings in .env.bak-2026-07-28. Those are
real credentials, they remain in history, and suppressing them before they are
rotated would hide a live exposure.

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant