Skip to content

fix(ci): use gitleaks dir mode so pre-commit catches secrets in CI#1556

Merged
pstjohn merged 2 commits intoNVIDIA:mainfrom
svc-bionemo:fix/gitleaks-precommit-dir-mode
Apr 20, 2026
Merged

fix(ci): use gitleaks dir mode so pre-commit catches secrets in CI#1556
pstjohn merged 2 commits intoNVIDIA:mainfrom
svc-bionemo:fix/gitleaks-precommit-dir-mode

Conversation

@svc-bionemo
Copy link
Copy Markdown
Collaborator

Problem

The gitleaks pre-commit hook is silently passing in CI, even when secrets are present. See #1551 which includes a hardcoded WANDB_API_KEY that gitleaks did not flag.

Root cause: The default gitleaks hook entry is:

gitleaks git --pre-commit --redact --staged --verbose

This scans staged git changes — it works during an actual git commit. But in CI, static_checks.sh runs:

pre-commit run --all-files

With --all-files, there are no staged files and no commit context, so gitleaks scans 0 commits and reports "no leaks found":

7:02PM INF 0 commits scanned.
7:02PM INF scanned ~0 bytes (0) in 28.9ms
7:02PM INF no leaks found

Fix

Override the hook entry to use gitleaks dir --redact --verbose, which scans file contents directly. This works correctly both:

  • Locally during git commit (pre-commit hook)
  • In CI with pre-commit run --all-files

Testing

After this change, running pre-commit run gitleaks --all-files on the repo will scan actual file contents instead of scanning 0 commits.

The default gitleaks pre-commit hook entry uses `gitleaks git --pre-commit
--staged`, which scans staged git changes. In CI, `pre-commit run
--all-files` has no staged files, so gitleaks scans 0 commits and always
passes — even when secrets are present in the codebase.

Switch to `gitleaks dir --redact --verbose` which scans actual file
contents. This works correctly both during local `git commit` hooks and
in CI with `--all-files`.

Signed-off-by: svc-bionemo <267129667+svc-bionemo@users.noreply.github.com>
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 20, 2026

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 7e6515ed-9405-4f41-abc9-b60a04d71fb6

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands and usage tips.

Signed-off-by: Peter St. John <pstjohn@nvidia.com>
@pstjohn pstjohn enabled auto-merge April 20, 2026 19:24
@pstjohn pstjohn added this pull request to the merge queue Apr 20, 2026
Merged via the queue into NVIDIA:main with commit 191c7dc Apr 20, 2026
17 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