Skip to content

fix(gitleaks): scan merge commits' own diffs - #40

Merged
CameronBrooks11 merged 1 commit into
mainfrom
fix/gitleaks-scan-merges
Oct 20, 2026
Merged

CameronBrooks11 merged 1 commit into
mainfrom
fix/gitleaks-scan-merges

Conversation

@CameronBrooks11

Copy link
Copy Markdown
Contributor

What

The Scan step now also scans each merge commit's own diff.

Why

git log -p shows 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-opts replaces 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:

  • default: git log -p -U0 --full-history --all --diff-filter=tuxdb
  • with this change: git log -p -U0 --all --full-history --diff-merges=first-parent --diff-filter=tuxdb

Testing

  • New tests/gitleaks-scan.test.sh runs the step's exact run: 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.
  • Against main's workflow only the merge-only case fails (exit 0, "no leaks found"). The other three are unchanged.
  • Across the full history of every FlowMatrix-AI repo (71 repos, 433 merge commits), finding counts are identical with and without this change. Total scan time was 59 s for both runs together.
  • The repo's own history scans clean with the new options.

#39 changes ci.yml to run every tests/*.test.sh, so this test runs in CI whichever of the two PRs merges first.

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.
@CameronBrooks11
CameronBrooks11 merged commit 557c5d7 into main Oct 20, 2026
2 checks passed
@CameronBrooks11
CameronBrooks11 deleted the fix/gitleaks-scan-merges branch October 20, 2026 19:13
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