Repository navigation
fix(gitleaks): scan merge commits' own diffs - #40
Merged
Merged
Conversation
git log -p shows no diff for a merge commit, so a secret introduced only in a merge resolution (in neither parent) was never scanned by the Scan step. Pass --log-opts with gitleaks' defaults restated (--all --full-history --diff-filter=tuxdb, as its debug log shows) plus --diff-merges=first-parent. Across every FlowMatrix-AI repo (433 merge commits) this changes no finding counts. tests/gitleaks-scan.test.sh runs the step's exact run: block; its merge case fails against the previous workflow.
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.
What
The Scan step now also scans each merge commit's own diff.
Why
git log -pshows no diff for a merge commit. A secret introduced only in a merge resolution, so present in neither parent, was never scanned. Those merges are evil merges or hand-resolved conflicts.How
--log-optsreplaces gitleaks' default git-log options. The new value keeps those defaults and adds--diff-merges=first-parent. gitleaks' debug log shows the commands it runs:git log -p -U0 --full-history --all --diff-filter=tuxdbgit log -p -U0 --all --full-history --diff-merges=first-parent --diff-filter=tuxdbTesting
tests/gitleaks-scan.test.shruns the step's exactrun:block with 4 cases: a clean repo, an ordinary commit, a merge-only token, and a token on a non-HEAD branch. All 4 pass.main's workflow only the merge-only case fails (exit 0, "no leaks found"). The other three are unchanged.#39 changes
ci.ymlto run everytests/*.test.sh, so this test runs in CI whichever of the two PRs merges first.