fix(ci): use gitleaks dir mode so pre-commit catches secrets in CI#1556
Merged
pstjohn merged 2 commits intoNVIDIA:mainfrom Apr 20, 2026
Merged
fix(ci): use gitleaks dir mode so pre-commit catches secrets in CI#1556pstjohn merged 2 commits intoNVIDIA:mainfrom
pstjohn merged 2 commits intoNVIDIA:mainfrom
Conversation
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>
Contributor
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
Signed-off-by: Peter St. John <pstjohn@nvidia.com>
pstjohn
approved these changes
Apr 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The gitleaks pre-commit hook is silently passing in CI, even when secrets are present. See #1551 which includes a hardcoded
WANDB_API_KEYthat gitleaks did not flag.Root cause: The default gitleaks hook entry is:
This scans staged git changes — it works during an actual
git commit. But in CI,static_checks.shruns:With
--all-files, there are no staged files and no commit context, so gitleaks scans 0 commits and reports "no leaks found":Fix
Override the hook entry to use
gitleaks dir --redact --verbose, which scans file contents directly. This works correctly both:git commit(pre-commit hook)pre-commit run --all-filesTesting
After this change, running
pre-commit run gitleaks --all-fileson the repo will scan actual file contents instead of scanning 0 commits.