Repository navigation
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
The Secret Scan job checked out with fetch-depth 0, which fetches every branch, and ran `gitleaks detect` with no --log-opts, i.e. `git log --all`. One open PR's finding therefore failed every other PR's Secret Scan until that branch was force-pushed (seen with fix/968's old commit failing #1011). Run `gitleaks git --log-opts="HEAD"` instead, keeping the full-history checkout: on pull_request HEAD is the merge commit, so main plus every PR commit is scanned (a secret added and removed within the PR is still caught); on push and schedule it is main's full history. workflow_secret_scan_test.go parses security.yml and fails if the gitleaks invocation loses --log-opts="HEAD", widens with --all/--branches/--remotes/ --glob, stops scanning git history, its job loses fetch-depth 0, or no gitleaks invocation is found. Fixes #1024
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1024
Problem
The Secret Scan job checks out with
fetch-depth: 0(fetches every branch) and rangitleaks detect --source .with no--log-opts, which gitleaks 8.21.2 turns intogit log --all. So one branch's finding failed every open PR's Secret Scan (fix/968's old commit 4453716 failing #1011 and fix/1015).Change
security.yml:gitleaks git --log-opts="HEAD" --redact --verbose --exit-code 1 .. Checkout staysfetch-depth: 0so leaked-then-removed secrets are still caught. Onpull_requestHEAD isrefs/pull/N/merge, whose ancestry is main plus every PR commit; onpush/scheduleit is main's full history. Same pinned, hash-verified gitleaks 8.21.2; no action pins changed.workflow_secret_scan_test.go(new gate): parsessecurity.yml, and fails if any gitleaks invocation lacks--log-opts="HEAD", widens it (--all/--branches/--remotes/--glob), doesn't scan git history (dir/--no-git), runs in a job without anactions/checkoutwithfetch-depth: 0, or if no gitleaks invocation is found at all. Comment lines are dropped so the explanatory comment cannot satisfy it.Verification (local, pinned gitleaks 8.21.2 darwin_arm64, sha256 checked against the release's checksums.txt)
In a fresh clone of this repo with all remote branches (like CI), a throwaway local branch added a generated
AKIA…fake key (never pushed; branch and clone deleted afterwards):detect --source .git --log-opts=HEAD--no-ffmerge of temp branch into main (likerefs/pull/N/merge)Gate watched failing against four compiling reverts: old invocation,
fetch-depth: 1,--log-opts="HEAD --all", and deleting the scan line.make checkpasses apart from the known Docker-onlyTestGenerateWrapper_ChownFixesCrossUIDStickyUnlink_Docker;make check-nestedandmake check-tidypass.