Skip to content

ci(secrets): scan by level — a pull request on its own commits, the default branch on its history, the weekly run on every ref - #3

Merged
PabloFMM merged 1 commit into
mainfrom
ci/secrets-scan-by-level
Oct 29, 2026
Merged

PabloFMM merged 1 commit into
mainfrom
ci/secrets-scan-by-level

Conversation

@numinia-ci-puerta

Copy link
Copy Markdown
Contributor

Why

secrets.yml checks out with fetch-depth: 0 and runs gitleaks git ., which reads every ref of the clone, remote branches included. A false alarm on one branch (numinia-web #290, 4× generic-api-key on an account id) turned the scan check red on every other open pull request in that repository, until the branch was deleted.

What

Same job, three scopes, chosen from the calling workflow's event:

  • pull_request / merge_group: only the commits the change adds (base..HEAD). Blocks that PR, and only it.
  • push to the default branch: the whole history of that branch (HEAD).
  • weekly schedule / manual run: every ref (--all, gitleaks' default), branches included. A red run here warns; it blocks no PR.

If a base commit is missing, it falls back to the whole branch history. Config handling, the checksum-verified binary and --redact are unchanged. fetch-depth: 0 stays: the range needs the base.

Checked locally (gitleaks 8.30.1, numinia-web history with a leaky branch next to a clean one)

  • PR on the clean branch: exit 0 (the leaky branch is not read)
  • PR on the leaky branch: exit 1
  • history of the clean branch: exit 0
  • --all: exit 1 (finds the leak on the other branch)

After merge

Callers pin this file by SHA. Bump the pin in each repository (one PR each). Callers that should run the weekly level need schedule: in their secrets.yml (numinia-web has it) and merge_group: if the scan should run in the queue.

…efault branch on its history, the weekly run on every ref
@PabloFMM
PabloFMM self-requested a review October 29, 2026 14:05
@PabloFMM
PabloFMM merged commit 05ab0e2 into main Oct 29, 2026
4 checks passed
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.

2 participants