Skip to content

gitleaks job scans every branch, so one branch's finding fails every open PR's Secret Scan #1024

Closed

Description

@scttfrdmn

security.yml's gitleaks job checks out with fetch-depth: 0, which fetches every branch, and then runs gitleaks detect --source .. That scans the history of every fetched ref (git log --all), not just the PR's commits plus main.

What I saw: #1011 (fix/1004) failed Secret Scan with a finding in internal/hermetic/hermetic.go:76 from commit 4453716 ("Make unit tests hermetic ... (#968)"). That commit was on the then-head of fix/968 (#1003), not on fix/1004 or main. fix/1015 failed at the same time, probably for the same reason. Once fix/968 was force-pushed past it, re-running #1011's job passed with no change to #1011.

So one PR that contains a gitleaks hit, real or false positive, turns every other PR's Secret Scan red while it exists. That trains people to re-run the job until it passes. A commit that is later force-pushed away also stops being scanned, which undercuts the "leaked-then-removed secrets are caught" goal for unmerged branches.

Suggested: on pull_request, scan the PR's own range (gitleaks detect --log-opts="origin/${{ github.base_ref }}..HEAD", or git log over base..head). Keep the full-history scan on push to main / on a schedule, scoped to main's history.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions