Skip to content

Fix TruffleHog PR scans that silently scanned nothing - #2648

Merged
kevalmorabia97 merged 1 commit into
mainfrom
kmorabia/fix-trufflehog-pr-scan
Oct 2, 2026
Merged

kevalmorabia97 merged 1 commit into
mainfrom
kmorabia/fix-trufflehog-pr-scan

Conversation

@kevalmorabia97

@kevalmorabia97 kevalmorabia97 commented Oct 2, 2026 •

Copy link
Copy Markdown
Collaborator

What does this PR do?

Type of change: Bug fix

The nightly code-quality run has failed every night since #2514 merged (e.g. run 36648252702), even though every PR passes.

Root cause: on pull_request, actions/checkout does a depth-1 clone, so the PR's base commit is missing. TruffleHog logs unable to resolve commit: object not found, scans 0 chunks, and exits 0. Every recent PR run shows "chunks": 0, so the PR secret scan has been a no-op. Nightly has no base to diff against and scans the whole tree, so it is the only run that actually checks anything.

Changes:

  • code_quality.yml: fetch full history on PRs (fetch-depth: 0) so --since-commit <base> resolves. Nightly stays shallow, so it keeps scanning the current tree instead of all of git history. ('0' is a string because the number 0 is falsy in expressions and would fall through to 1.)
  • test_mlflow.py: # trufflehog:ignore only applies to its own line. The marker sat on the closing ), not on the two credential-URI lines that were flagged (1260, 1264). I moved it onto those lines and shortened one test password so the line fits the 100-char limit; it still tests a percent-encoded /.

Heads-up: now that PR scans actually run, PRs that add secret-looking strings will fail the scan, as intended.

Testing

  • Reproduced the PR-mode scan for [2/2] Track every Megatron-Bridge script with MLflow #2514 with full history, using trufflehog 3.97.9 (the version CI pulls): it reports the same two URI findings at lines 1260 and 1264 and exits 183, so it would have blocked that PR.
  • Filesystem scan of the whole repo on this branch with CI's flags: no findings.
  • pytest tests/unit/torch/utils/test_mlflow.py -k credentials_move: 6 passed. pre-commit passes on the changed files.

Before your PR is "Ready for review"

  • Is this change backward compatible?: ✅
  • If you copied code from any other sources or added a new PIP dependency, did you follow guidance in CONTRIBUTING.md: N/A
  • Did you write any new necessary tests?: N/A
  • Did you update Changelog?: N/A
  • Did you get Claude approval on this PR?: N/A

Additional Information

The action pulls trufflehog:latest, so new upstream detectors can change results. It could be pinned via the action's version: input; this PR leaves that unchanged.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Tests
    • Updated credential-handling test coverage to verify that percent-encoded passwords are interpreted correctly.
  • Chores
    • Pull-request quality checks now fetch full repository history, while checks for other events continue to use a shallow checkout.

The shallow PR checkout lacks the base commit, so TruffleHog failed to
resolve it, scanned 0 chunks, and passed. Fetch full history on PRs, and
move the trufflehog:ignore markers in test_mlflow.py onto the lines the
nightly scan flags.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Signed-off-by: Keval Morabia <[email protected]>
@kevalmorabia97
kevalmorabia97 requested review from a team as code owners October 2, 2026 23:19
@coderabbitai

coderabbitai Bot commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: NVIDIA/Model-Optimizer/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Enterprise
  • Run ID: 7e1b9370-4dc5-4d27-b224-7736946ebcb9
📥 Commits

Reviewing files that changed from the base of the PR and between 472c94d and d00b478.

📒 Files selected for processing (2)
  • .github/workflows/code_quality.yml
  • tests/unit/torch/utils/test_mlflow.py

Included review availability: This review used your included allowance. Your plan provides up to 12 included reviews per hour; 11 remain after this review.


📝 Walkthrough

Walkthrough

The workflow checkout depth now varies by event type. The MLflow credential-splitting test expects the percent-encoded password to decode to t/k, with the TruffleHog ignore annotation on that URI.

Changes

Workflow checkout

Layer / File(s) Summary
Set checkout fetch depth
.github/workflows/code_quality.yml
The checkout step sets fetch depth to 0 for pull requests and 1 for other events.

MLflow credential test

Layer / File(s) Summary
Update credential-splitting test
tests/unit/torch/utils/test_mlflow.py
The percent-encoded userinfo case expects password t/k. Its TruffleHog ignore annotation is on that URI.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Suggested reviewers: cjluo-nv

Merge Risk: ⚪ Minimal · up to d00b4

Pull-request scans can compare against the base commit, and the credential test expects the decoded password. No actionable merge-blocking risk remains.

🚥 Pre-merge checks | ✅ 6
✅ Passed checks (6 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the main change: fixing TruffleHog pull-request scans that completed without scanning content.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 1 files. (1 skipped: 1 …
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Security Anti-Patterns ✅ Passed PASS. The authoritative PR diff changes only .github/workflows/code_quality.yml and tests/unit/torch/utils/test_mlflow.py; it contains no modelopt/ or examples/ Python changes. The added Pytho…
✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Autopilot is currently an internal CodeRabbit preview.


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

@kevalmorabia97
kevalmorabia97 enabled auto-merge (squash) October 2, 2026 23:30
@codecov

codecov Bot commented Oct 2, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 68.10%. Comparing base (b1b66cb) to head (d00b478).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2648      +/-   ##
==========================================
- Coverage   68.74%   68.10%   -0.65%     
==========================================
  Files         619      620       +1     
  Lines       69539    70276     +737     
==========================================
+ Hits        47808    47861      +53     
- Misses      21731    22415     +684     
Flag Coverage Δ
unit 58.67% <ø> (-0.06%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@kevalmorabia97
kevalmorabia97 merged commit a57c5eb into main Oct 2, 2026
44 checks passed
@kevalmorabia97
kevalmorabia97 deleted the kmorabia/fix-trufflehog-pr-scan branch October 2, 2026 23:45
@github-actions

github-actions Bot commented Oct 2, 2026

Copy link
Copy Markdown
Contributor
PR Preview Action v1.8.1
Preview removed because the pull request was closed.
2026-10-02 23:46 UTC

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