Skip to content

ci(security): scan only the checked-out history in the Gitleaks job - #1633

Merged
lusoris merged 3 commits into
masterfrom
ci/gitleaks-scan-checked-out-history
Sep 30, 2026
Merged

lusoris merged 3 commits into
masterfrom
ci/gitleaks-scan-checked-out-history

Conversation

@lusoris

@lusoris lusoris commented Sep 29, 2026

Copy link
Copy Markdown
Contributor

Summary

On 2026-09-29, #1628 failed its Gitleaks check on build-config.env:218 of commit a74842e16. #1628 does not contain that commit. The commit was a pre-rebase version of fix/release-oneapi-image-runtime (#1629), and a force-push had already replaced it. The finding itself was a generic-api-key false positive on an apt signing-key fingerprint.

The job checks out with fetch-depth: 0, which fetches every branch, and runs gitleaks detect without --log-opts. In that case gitleaks runs git log --full-history --all, so every pull request scanned every branch in the repository. One branch's finding therefore failed all the others, including findings in commits that had already been replaced.

This PR passes --log-opts="--full-history HEAD". On a pull request, HEAD is the merge commit, so the scan covers master's history plus the PR's own commits. On pushes to master and on the schedule, it covers master. A new self-test step pins the option.

Type

  • build / ci — tooling / infra

Checklist

  • Commits follow Conventional Commits (the commit-msg hook enforces this).
  • make format && make lint is green locally. Not run in full: one workflow step and one Python test changed; actionlint and the test pass.
  • Unit tests pass: python3 scripts/ci/run_meson_test.py -- -C build. Not applicable: no native code changed.

Bug-status hygiene (ADR-0165)

  • T-CI-GITLEAKS-SCANS-ALL-BRANCHES-2026-09-29 added to Recently closed.

Netflix golden-data gate (ADR-0024)

  • I did not modify any assertAlmostEqual(...) score in the Netflix golden Python tests.

Deep-dive deliverables (ADR-0108)

  • Research digest — no digest needed: trivial scan-scope fix.
  • Decision matrix — no alternatives: only-one-way fix. Scanning base..head instead would skip master's history on pull requests, and dropping fetch-depth: 0 would break the history scan.
  • AGENTS.md invariant note — no rebase-sensitive invariants; the self-test enforces the option.
  • Reproducer / smoke-test command — see below.
  • CHANGELOG fragment — changelog.d/fixed/gitleaks-scan-checked-out-history.md.
  • Rebase note — no rebase impact: fork-only workflow.

no docs needed: CI-internal scan scope with no user-discoverable surface.

Reproducer

python3 -B scripts/ci/tests/test_gitleaks_scan_scope.py          # 5 tests OK
docker run --rm -v "$PWD:/src:ro" --entrypoint sh zricethezav/gitleaks:v8.24.3 -c \
  'git config --global --add safe.directory "*"; gitleaks detect --source /src \
   --log-opts="--full-history HEAD" --config /src/.gitleaks.toml --redact --exit-code 1'
# master 2d9d5b069: 4752 commits scanned, no leaks found, exit 0

Negative control: with the --log-opts line removed, test_scans_checked_out_history_only fails.

Scope change: branches without an open pull request are no longer scanned by this job. GitHub secret scanning still covers every push.

🤖 Generated with Claude Code

@github-actions github-actions Bot added the type:ci CI and infrastructure label Sep 29, 2026
@lusoris
lusoris force-pushed the ci/gitleaks-scan-checked-out-history branch from 189e0ea to 59e6308 Compare September 29, 2026 16:47
lusoris and others added 3 commits September 30, 2026 13:41
gitleaks ran git log --all over a fetch-depth: 0 checkout, so a finding on
any branch, even a force-pushed-away commit still in the fetch, failed every
other pull request (#1628 on 2026-09-29). Pass --log-opts so each run scans
HEAD's history: master plus the PR's commits on a pull request.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@lusoris
lusoris force-pushed the ci/gitleaks-scan-checked-out-history branch from 59e6308 to b99bef0 Compare September 30, 2026 11:43
@lusoris
lusoris merged commit b61b4d1 into master Sep 30, 2026
102 checks passed
@lusoris
lusoris deleted the ci/gitleaks-scan-checked-out-history branch September 30, 2026 12:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type:ci CI and infrastructure

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant