Skip to content

fix(review): scan patch-less PR files for leaked secrets - #3481

Closed
RealDiligent wants to merge 3 commits into
JSONbored:mainfrom
RealDiligent:fix/secret-scan-patchless-files-v4
Closed

fix(review): scan patch-less PR files for leaked secrets#3481
RealDiligent wants to merge 3 commits into
JSONbored:mainfrom
RealDiligent:fix/secret-scan-patchless-files-v4

Conversation

@RealDiligent

Copy link
Copy Markdown
Contributor

Problem

GitHub omits inline patch for binary/large PR files; the unconditional secret_leak gate only scanned inline diff + lines, so credentials in patch-less files could bypass the hard blocker.

Fix

  • src/queue/patchless-secret-scan.ts — fetch head/base via Contents API, synthesize scannable + lines, fail closed on oversized/unfetchable content.
  • Wired into maybeAddSecretLeakFinding at gate time.

Pre-PR validation

  • npm run typecheck
  • test/unit/patchless-secret-scan.test.ts (41 tests, 100% patch coverage locally)

Supersedes closed #3473 (codecov passed but auto-closed without merge).

RealDiligent and others added 3 commits July 5, 2026 16:50
)

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>
Co-authored-by: Cursor <cursoragent@cursor.com>
@RealDiligent
RealDiligent requested a review from JSONbored as a code owner July 5, 2026 09:22
@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

Caution

🟥🟥🟥🟥🟥🟥🟥🟥🟥🟥🟥🟥

🛑 Gittensory review result - reject/close recommended

Review updated: 2026-07-05 09:24:33 UTC

3 files · 1 AI reviewer · 1 blocker · readiness 80/100 · CI pending · blocked

🛑 Suggested Action - Reject/Close

  • AI reviewers agree on a likely critical defect: src/queue/patchless-secret-scan.ts:128 passes SECRET_SCAN_PATCH_FALLBACK_MAX_CHARS as the fetch limit and then checks `headContent.length > SECRET_SCAN_PATCH_FALLBACK_MAX_CHARS`, but the existing grounding caller uses `limit + 1` specifically to detect truncation, so a real oversized patch-less file can be truncated to exactly 512000 chars, treated as complete, and hide a secret after the cap
  • change the head/base fetches to request `SECRET_SCAN_PATCH_FALLBACK_MAX_CHARS + 1` before the existing `isOverSecretScanContentLimit` checks. — Resolve the flagged defect, or override if the AI reviewers are mistaken, then re-run the gate.

Review summary
This change wires a patch-less file fallback into the deterministic secret scan and the main flow is pointed at the right gate path: it fetches head/base content, synthesizes added lines, and emits a critical finding when content cannot be fully scanned. The important correctness gap is at the fetch boundary: the new code tests an oversized branch that the real fetcher contract may never expose because it passes the scan cap as the fetch limit instead of cap+1, so secrets after the cap can still be hidden in a large patch-less file. The PR also only references a closed superseded PR, not an eligible open issue, which violates this repo's contributor-scope requirement.

Blockers

  • src/queue/patchless-secret-scan.ts:128 passes SECRET_SCAN_PATCH_FALLBACK_MAX_CHARS as the fetch limit and then checks `headContent.length > SECRET_SCAN_PATCH_FALLBACK_MAX_CHARS`, but the existing grounding caller uses `limit + 1` specifically to detect truncation, so a real oversized patch-less file can be truncated to exactly 512000 chars, treated as complete, and hide a secret after the cap; change the head/base fetches to request `SECRET_SCAN_PATCH_FALLBACK_MAX_CHARS + 1` before the existing `isOverSecretScanContentLimit` checks.
  • PR description: the only linked reference is closed fix(review): scan patch-less PR files for leaked secrets #3473, but this repo requires external contributor PRs to close or clearly link an eligible open issue, so link the open maintainer-authorized issue this fixes or explain why this is maintainer-authorized.
Nits — 5 non-blocking
  • test/unit/patchless-secret-scan.test.ts:424 fabricates a real fetcher returning 512001 chars even though the production fetch limit is currently 512000, so that test covers the intended branch without proving the actual Contents API path reaches it.
  • src/queue/patchless-secret-scan.ts:79 includes every incomplete path verbatim in one finding detail, which can become noisy on a PR with many patch-less generated files; consider capping the displayed list while keeping the count exact.
  • src/queue/patchless-secret-scan.ts:128,143,153 should mirror the existing full-file grounding pattern: `const fetchLimit = SECRET_SCAN_PATCH_FALLBACK_MAX_CHARS + 1;` and pass `fetchLimit` to every `getFileContent` call, then keep `isOverSecretScanContentLimit` as the fail-closed detector.
  • test/unit/patchless-secret-scan.test.ts:424 should assert the fetcher receives `512001` and returns a `512001`-char body so the oversized test exercises the real production contract instead of an impossible mocked payload.
  • PR description should add the eligible open issue link in the closing format expected by the maintainer gate.

Why this is blocked

  • src/queue/patchless-secret-scan.ts:128 passes SECRET_SCAN_PATCH_FALLBACK_MAX_CHARS as the fetch limit and then checks `headContent.length > SECRET_SCAN_PATCH_FALLBACK_MAX_CHARS`, but the existing grounding caller uses `limit + 1` specifically to detect truncation, so a real oversized patch-less file can be truncated to exactly 512000 chars, treated as complete, and hide a secret after the cap; change the head/base fetches to request `SECRET_SCAN_PATCH_FALLBACK_MAX_CHARS + 1` before the existing `isOverSecretScanContentLimit` checks.
Signal Result Evidence
Code review ❌ 1 blocker 1 reviewer
Linked issue ✅ Linked #3473
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: 138 registered-repo PR(s), 18 merged, 0 issue(s).
Contributor context ✅ Confirmed Gittensor contributor RealDiligent; Gittensor profile; 138 PR(s), 0 issue(s).
Gate result ❌ Blocking Repo-configured hard 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: Ruby, Svelte, TypeScript, Cuda, JavaScript, Markdown
  • Official Gittensor activity: 138 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

@loopover-orb

loopover-orb Bot commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

Gittensory is closing this pull request on the maintainer's behalf (AI reviewers agree on a likely critical defect: src/queue/patchless-secret-scan.ts:128 passes SECRET_SCAN_PATCH_FALLBACK_MAX_CHARS as the fetch limit and then checks `headContent.length > SECRET_SCAN_PATCH_FALLBACK_MAX_CHARS`, but the existing grounding caller uses `limit + 1` specifically to detect truncation, so a real oversized patch-less file can be truncated to exactly 512000 chars, treated as complete, and hide a secret after the cap; change the head/base fetches to request `SECRET_SCAN_PATCH_FALLBACK_MAX_CHARS + 1` before the existing `isOverSecretScanContentLimit` checks.). This is an automated maintenance action — to pursue this change, please open a new pull request with the issues resolved. Closed PRs may be analyzed later to improve review accuracy, but they are not automatically reopened or re-reviewed.

@loopover-orb loopover-orb Bot closed this Jul 5, 2026
@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.05%. Comparing base (a979552) to head (50a8bb1).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3481      +/-   ##
==========================================
+ Coverage   93.03%   93.05%   +0.01%     
==========================================
  Files         298      299       +1     
  Lines       31203    31281      +78     
  Branches    11386    11414      +28     
==========================================
+ Hits        29029    29107      +78     
  Misses       1518     1518              
  Partials      656      656              
Files with missing lines Coverage Δ
src/queue/patchless-secret-scan.ts 100.00% <100.00%> (ø)
src/queue/processors.ts 93.40% <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 Bot pushed a commit that referenced this pull request Jul 5, 2026
…#3493)

* fix(review): scan patch-less PR files for leaked secrets (#2821)

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>

* test(review): cover default-status branch for patch-less secret scan (#3464)

Co-authored-by: Cursor <cursoragent@cursor.com>

* fix(review): use +1 fetch probe for patch-less secret scan cap (#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>

* fix(review): precheck patch-less fetch and cap incomplete-path detail

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>

---------

Co-authored-by: Cursor <cursoragent@cursor.com>
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