Skip to content

Action — secret-scan ​

Scans the commits a run brings for leaked secrets with Gitleaks. The configuration and the ignore list are read from a trusted commit, never from the commits under scan, so a change cannot allowlist its own leak. It is the secret scan of security.yml, which adds the checkout and the SARIF upload around it.

Usage ​

yaml
steps:
  - uses: actions/checkout@v7
    with:
      fetch-depth: 0 # the scan walks base..HEAD
      persist-credentials: false

  - id: base
    uses: KevinDeBenedetti/github-workflows/.github/actions/change-base@main

  - uses: KevinDeBenedetti/github-workflows/.github/actions/secret-scan@main
    with:
      base: ${{ steps.base.outputs.base }}

Inputs ​

InputDefaultDescription
base''The change base: the base output of change-base, run without fetch-base. Empty scans everything
ignore-inline-allowfalseIgnore inline gitleaks:allow comments (gitleaks --ignore-gitleaks-allow)
report-pathresults.sarifSARIF report to write

The step fails (exit 1) when Gitleaks finds a leak. Findings are redacted in the log; the SARIF report holds their file and line.

Scanned range ​

  • With a change base: base..HEAD, merge commits left out. No --first-parent: on a pull request HEAD is the merge commit GitHub prepares, and after a merge to the default branch the feature commits sit behind the second parent.
  • Without one (a manual or scheduled run, a change base outside a shallow clone): all fetched history.

Trusted commit ​

Run.gitleaks.toml and .gitleaksignore are read from
A change base is setThe change base
Manual runThe default branch, when the clone holds it
Scheduled runHEAD, the default branch's own tip
Anything elseNowhere: Gitleaks' default rules and an empty ignore list, with a warning
  • A trusted .gitleaks.toml that [extend]s a path inside the repository gets that file restored from the trusted commit too. A path outside the repository (absolute, or with ..), or missing from the trusted commit, fails the step.
  • The working tree's .gitleaksignore is overwritten with the trusted copy: Gitleaks always reads it, on top of the one it is given.
  • With a range, the step warns when the range changes the configuration, the ignore list or the extended file (not applied to this scan), and when it adds gitleaks:allow comments.

Notes ​

  • Pass base from change-base without fetch-base: the scan walks the commits between the base and HEAD, which a fetched single commit does not provide. A base that is not in the clone fails the step.
  • Gitleaks is downloaded from its GitHub release and checked against a SHA-256 pinned in the action. After a version bump, refresh it with scripts/update-tool-checksums.py.
  • Locally, with gitleaks on the PATH: BASE=<sha> bash .github/actions/secret-scan/secret-scan.sh.