Skip to content

fix(review): scan patch-less PR files for leaked secrets (#audit-3.4) - #3493

Merged
loopover-orb[bot] merged 4 commits into
JSONbored:mainfrom
RealDiligent:fix/secret-scan-patchless-files-v6
Jul 5, 2026
Merged

fix(review): scan patch-less PR files for leaked secrets (#audit-3.4)#3493
loopover-orb[bot] merged 4 commits into
JSONbored:mainfrom
RealDiligent:fix/secret-scan-patchless-files-v6

Conversation

@RealDiligent

Copy link
Copy Markdown
Contributor

Summary

Closes the patch-less bypass gap in the unconditional secret_leak hard blocker (#audit-3.4). GitHub omits inline patch for binary/large PR files; without Contents API fallback, credentials in those files evaded the gate.

Supersedes closed #2821, #3464, #3473, #3481, #3484.

Fix

  • src/queue/patchless-secret-scan.ts — Contents API fallback synthesizing scannable + lines; +1 fetch probe so oversized files fail closed (not truncated-prefix scan)
  • Wire into maybeAddSecretLeakFinding with installationId, headSha, baseSha
  • Precheck — skip makeGithubFileFetcher when every changed file already has inline patch (fix(review): scan patch-less PR files for leaked secrets #3484 review nit)
  • Detail cap — incomplete-path advisory lists first 5 paths + remainder count

Linked issue / authorization

No dedicated upstream tracking issue existed before contributor attempts #2821#3484 (the last passed CI + codecov but was auto-closed for missing a pre-existing issue link). This PR implements the security fix those PRs described — completing an outstanding hole in the #audit-3.4 unconditional blocker (shipped in #1237; parent self-host review-gap audit #1936).

Test plan

  • npm run typecheck
  • test/unit/patchless-secret-scan.test.ts — 44 tests, 100% line coverage on patchless-secret-scan.ts locally

RealDiligent and others added 4 commits July 5, 2026 18:56
)

Extract patch-less secret-scan enrichment into patchless-secret-scan.ts with
full unit coverage. When GitHub omits inline diff for binary/large files,
fetch head/base content via Contents API and synthesize scannable + lines
before the unconditional secret_leak hard blocker runs.

Co-authored-by: Cursor <cursoragent@cursor.com>
…ored#3481)

The grounding FileFetcher returns maxChars+1 when content exceeds the cap;
pass SECRET_SCAN_FETCH_PROBE_CHARS so oversized files fail closed instead of
scanning a truncated prefix.

Co-authored-by: Cursor <cursoragent@cursor.com>
Skip makeGithubFileFetcher when every file already has inline patch.
Cap fail-closed advisory path list (title keeps full count).

Co-authored-by: Cursor <cursoragent@cursor.com>
@RealDiligent
RealDiligent requested a review from JSONbored as a code owner July 5, 2026 11:09
@superagent-security

Copy link
Copy Markdown
Contributor

Superagent didn't find any vulnerabilities or security issues in this PR.

@loopover-orb loopover-orb Bot added the gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier. label Jul 5, 2026
@loopover-orb

loopover-orb Bot commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

Warning

🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨

⏸️ Gittensory review result - manual review recommended

Review updated: 2026-07-05 11:15:09 UTC

3 files · 1 AI reviewer · no blockers · readiness 80/100 · CI green · clean

⏸️ Suggested Action - Manual Review

Review summary
The change adds a bounded Contents API fallback for patch-less PR files and wires it into the deterministic secret-leak scan before building the scan corpus. The main security path is covered: patch-less added files are scanned from head content, modified/renamed files diff against base content, and unreadable or oversized eligible files fail closed with an advisory finding. I do not see a reachable correctness break in the provided diff; the notable residual risk is around defensive handling of unusual PR file statuses or missing head/base metadata rather than the implemented hot path.

Nits — 5 non-blocking
  • nit: test/unit/patchless-secret-scan.test.ts:1 starts with a UTF-8 BOM before the import; remove it so the new test file matches the repo's normal ASCII/UTF-8-without-BOM style.
  • nit: src/queue/patchless-secret-scan.ts:49 treats any non-added/non-modified/non-renamed status as ineligible, so confirm this repository never receives GitHub's less-common PR file statuses as modified-equivalent before relying on the fallback for every patch-less text change.
  • nit: src/queue/processors.ts:6768 logs only the repository and pull number when fallback setup fails; adding the count of eligible patch-less files would make fail-closed incidents easier to triage without exposing file content.
  • src/queue/patchless-secret-scan.ts:47: add an explicit test or comment for the PR file statuses emitted by listPullRequestFiles so future status-normalization changes do not silently skip patch-less candidates.
  • test/unit/patchless-secret-scan.test.ts:1: remove the BOM from the new test file.
Signal Result Evidence
Code review ✅ No blockers 1 reviewer
Linked issue ✅ Linked #2821
Related work ✅ No active overlap found No same-issue or scoped active PR overlap found.
Change scope ✅ 20/20 Low review scope from cached public metadata (1 linked issue).
Validation posture ❌ 5/25 Preflight is holding this PR: the review lane is unavailable, so it is not ready for automated review.
Contributor workload ✅ 10/10 Author activity: 146 registered-repo PR(s), 19 merged, 0 issue(s).
Contributor context ✅ Confirmed Gittensor contributor RealDiligent; Gittensor profile; 146 PR(s), 0 issue(s).
Gate result ✅ Passing No configured blocker found.
Review context
  • Author: RealDiligent
  • Role context: outside_contributor
  • Public audience mode: oss maintainer
  • Lane context: Repository registration is not available in the local Gittensory cache.
  • Public profile languages: JavaScript, Ruby, Svelte, TypeScript, Cuda, Markdown
  • Official Gittensor activity: 146 PR(s), 0 issue(s).
  • PR-specific overlap: none found.
Contributor next steps
  • Await review-lane availability.
  • Refresh registry data or choose a registered active repo.
Signal definitions
  • Related work = same linked issue, overlapping active PRs, or title/path similarity.
  • Change scope = cached public metadata such as size labels, draft state, and review-burden hints.
  • Validation posture = whether the PR provides enough public validation/test evidence for maintainer review.
  • Contributor workload = public contributor activity and cleanup pressure, not a repo-wide quality failure.
  • Contributor context = public GitHub/Gittensor identity context; non-Gittensor status is not a blocker.

🟩 Safe / merged · 🟦 Advisory · 🟨 Held for review · 🟥 Blocked / closed


💰 Earn for open-source contributions like this. Gittensor lets GitHub contributors earn for the work they already do — register to start earning →.

Checked by Gittensory, a quiet PR intelligence layer for OSS maintainers.

  • Re-run Gittensory review

@codecov

codecov Bot commented Jul 5, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.06%. Comparing base (6452202) to head (788bd89).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3493      +/-   ##
==========================================
+ Coverage   93.04%   93.06%   +0.01%     
==========================================
  Files         299      300       +1     
  Lines       31211    31298      +87     
  Branches    11389    11421      +32     
==========================================
+ Hits        29039    29126      +87     
  Misses       1517     1517              
  Partials      655      655              
Files with missing lines Coverage Δ
src/queue/patchless-secret-scan.ts 100.00% <100.00%> (ø)
src/queue/processors.ts 93.48% <100.00%> (+0.02%) ⬆️
🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@loopover-orb loopover-orb Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gittensory approves — the gate is satisfied and CI is green.

@loopover-orb
loopover-orb Bot merged commit 458f83e into JSONbored:main Jul 5, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant