fix(review): scan patch-less PR files for leaked secrets - #2821
fix(review): scan patch-less PR files for leaked secrets#2821RealDiligent wants to merge 13 commits into
Conversation
Codecov Report❌ Patch coverage is
❌ Your patch check has failed because the patch coverage (98.73%) is below the target coverage (99.00%). You can increase the patch coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## main #2821 +/- ##
=======================================
Coverage 96.00% 96.01%
=======================================
Files 258 258
Lines 28251 28329 +78
Branches 10275 10303 +28
=======================================
+ Hits 27123 27200 +77
Misses 491 491
- Partials 637 638 +1
🚀 New features to boost your workflow:
|
Exercise enrichSecretScanFilesWithPatchFallback edge cases and the maybeAddSecretLeakFinding headSha wiring path so patch coverage meets the 99% Codecov gate on JSONbored#2821. Co-authored-by: Cursor <cursoragent@cursor.com>
|
Caution 🟥🟥🟥🟥🟥🟥🟥🟥🟥🟥🟥🟥 🛑 Gittensory review result - fixes requiredReview updated: 2026-07-04 01:35:28 UTC
🛑 Suggested Action - Fix Blockers
Review summary Nits — 7 non-blocking
CI checks failing
Review context
Contributor next steps
Signal definitions
🟩 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.
|
…red#2821) Isolate patch-less enrichment failures so inline patches still scan, catch per-file Contents API errors without blocking siblings, and add regression tests for the fallback paths Codecov and the gate reviewer flagged. Co-authored-by: Cursor <cursoragent@cursor.com>
…red#2821) Do not treat a failed base fetch as empty content, diff renamed files against previousFilename at baseSha, and skip truncated oversize fetches so pre-existing secrets are not mis-flagged as new leaks. Co-authored-by: Cursor <cursoragent@cursor.com>
…SONbored#2821) Update workflow-runner-labels expectations after main moved CI/audit to ubuntu-latest (JSONbored#2825), and scan the leading 512KB of over-cap patch-less files instead of skipping them entirely. Co-authored-by: Cursor <cursoragent@cursor.com>
Exercise enrichSecretScanFilesWithPatchFallback edge cases and the maybeAddSecretLeakFinding headSha wiring path so patch coverage meets the 99% Codecov gate on JSONbored#2821. Co-authored-by: Cursor <cursoragent@cursor.com>
…red#2821) Isolate patch-less enrichment failures so inline patches still scan, catch per-file Contents API errors without blocking siblings, and add regression tests for the fallback paths Codecov and the gate reviewer flagged. Co-authored-by: Cursor <cursoragent@cursor.com>
…red#2821) Do not treat a failed base fetch as empty content, diff renamed files against previousFilename at baseSha, and skip truncated oversize fetches so pre-existing secrets are not mis-flagged as new leaks. Co-authored-by: Cursor <cursoragent@cursor.com>
…d#2821) Mark patch-less files over the 512KB fetch cap as incomplete and emit a secret_leak blocker instead of scanning a truncated prefix. Bound Contents API concurrency during enrichment and drop the unrelated workflow test hunk by rebasing onto main. Co-authored-by: Cursor <cursoragent@cursor.com>
a222414 to
e352244
Compare
Exercise enrichSecretScanFilesWithPatchFallback edge cases and the maybeAddSecretLeakFinding headSha wiring path so patch coverage meets the 99% Codecov gate on JSONbored#2821. Co-authored-by: Cursor <cursoragent@cursor.com>
…red#2821) Isolate patch-less enrichment failures so inline patches still scan, catch per-file Contents API errors without blocking siblings, and add regression tests for the fallback paths Codecov and the gate reviewer flagged. Co-authored-by: Cursor <cursoragent@cursor.com>
…red#2821) Do not treat a failed base fetch as empty content, diff renamed files against previousFilename at baseSha, and skip truncated oversize fetches so pre-existing secrets are not mis-flagged as new leaks. Co-authored-by: Cursor <cursoragent@cursor.com>
…d#2821) Mark patch-less files over the 512KB fetch cap as incomplete and emit a secret_leak blocker instead of scanning a truncated prefix. Bound Contents API concurrency during enrichment and drop the unrelated workflow test hunk by rebasing onto main. Co-authored-by: Cursor <cursoragent@cursor.com>
…bored#2821) Mark patch-less files incomplete when Contents API fetch fails or returns partial content, instead of silently skipping header-only entries. Co-authored-by: Cursor <cursoragent@cursor.com>
e352244 to
1873245
Compare
…ed#2821) Exercise renamed/modified oversize paths, incomplete finding wiring, default modified status, and bounded-concurrency fan-out for Codecov patch. Co-authored-by: Cursor <cursoragent@cursor.com>
4d2bd26 to
4b6c20b
Compare
Exercise enrichSecretScanFilesWithPatchFallback edge cases and the maybeAddSecretLeakFinding headSha wiring path so patch coverage meets the 99% Codecov gate on JSONbored#2821. Co-authored-by: Cursor <cursoragent@cursor.com>
…red#2821) Isolate patch-less enrichment failures so inline patches still scan, catch per-file Contents API errors without blocking siblings, and add regression tests for the fallback paths Codecov and the gate reviewer flagged. Co-authored-by: Cursor <cursoragent@cursor.com>
…red#2821) Do not treat a failed base fetch as empty content, diff renamed files against previousFilename at baseSha, and skip truncated oversize fetches so pre-existing secrets are not mis-flagged as new leaks. Co-authored-by: Cursor <cursoragent@cursor.com>
…d#2821) Mark patch-less files over the 512KB fetch cap as incomplete and emit a secret_leak blocker instead of scanning a truncated prefix. Bound Contents API concurrency during enrichment and drop the unrelated workflow test hunk by rebasing onto main. Co-authored-by: Cursor <cursoragent@cursor.com>
…bored#2821) Mark patch-less files incomplete when Contents API fetch fails or returns partial content, instead of silently skipping header-only entries. Co-authored-by: Cursor <cursoragent@cursor.com>
…ed#2821) Exercise renamed/modified oversize paths, incomplete finding wiring, default modified status, and bounded-concurrency fan-out for Codecov patch. Co-authored-by: Cursor <cursoragent@cursor.com>
…2821) Use nullish checks for Contents API fetch results so legitimately empty added/base files are scanned instead of hard-blocked as incomplete. Fix the incomplete-finding test to assert on detail, not title. Co-authored-by: Cursor <cursoragent@cursor.com>
Exercise enrichSecretScanFilesWithPatchFallback edge cases and the maybeAddSecretLeakFinding headSha wiring path so patch coverage meets the 99% Codecov gate on JSONbored#2821. Co-authored-by: Cursor <cursoragent@cursor.com>
…red#2821) Isolate patch-less enrichment failures so inline patches still scan, catch per-file Contents API errors without blocking siblings, and add regression tests for the fallback paths Codecov and the gate reviewer flagged. Co-authored-by: Cursor <cursoragent@cursor.com>
…red#2821) Do not treat a failed base fetch as empty content, diff renamed files against previousFilename at baseSha, and skip truncated oversize fetches so pre-existing secrets are not mis-flagged as new leaks. Co-authored-by: Cursor <cursoragent@cursor.com>
…d#2821) Mark patch-less files over the 512KB fetch cap as incomplete and emit a secret_leak blocker instead of scanning a truncated prefix. Bound Contents API concurrency during enrichment and drop the unrelated workflow test hunk by rebasing onto main. Co-authored-by: Cursor <cursoragent@cursor.com>
…bored#2821) Mark patch-less files incomplete when Contents API fetch fails or returns partial content, instead of silently skipping header-only entries. Co-authored-by: Cursor <cursoragent@cursor.com>
…ed#2821) Exercise renamed/modified oversize paths, incomplete finding wiring, default modified status, and bounded-concurrency fan-out for Codecov patch. Co-authored-by: Cursor <cursoragent@cursor.com>
…2821) Use nullish checks for Contents API fetch results so legitimately empty added/base files are scanned instead of hard-blocked as incomplete. Fix the incomplete-finding test to assert on detail, not title. Co-authored-by: Cursor <cursoragent@cursor.com>
…red#2821) Route removed files through shouldAttemptPatchLessSecretScan and add tests for blank headSha, renamed oversize head, and multi-path incomplete findings. Co-authored-by: Cursor <cursoragent@cursor.com>
4b6c20b to
d1f9e99
Compare
…red#2454) Port review-enrichment cross-line literal join into the unconditional secret_leak gate so credentials split across consecutive + lines cannot evade per-line regex matching. Preserves hunk/context boundaries and patch-less synthetic diffs from JSONbored#2821. Co-authored-by: Cursor <cursoragent@cursor.com>
…red#2454) Port review-enrichment cross-line literal join into the unconditional secret_leak gate so credentials split across consecutive + lines cannot evade per-line regex matching. Preserves hunk/context boundaries and patch-less synthetic diffs from JSONbored#2821. Co-authored-by: Cursor <cursoragent@cursor.com>
GitHub omits inline `patch` for binary/large changed files, so buildSecretScanDiff emitted header-only entries and secretLeakFinding had no `+` lines to scan — the unconditional `secret_leak` hard blocker could be bypassed by committing credentials in a patch-less file. When headSha is available, fetch post-change file content via the existing GitHub Contents fetcher and synthesize `+` lines: full head content for added/renamed files, multiset-added lines vs base for modified files when baseSha is known. Reuses makeGithubFileFetcher (never throws) so fetch failures degrade to the prior behavior. Co-authored-by: Cursor <cursoragent@cursor.com>
Exercise enrichSecretScanFilesWithPatchFallback edge cases and the maybeAddSecretLeakFinding headSha wiring path so patch coverage meets the 99% Codecov gate on JSONbored#2821. Co-authored-by: Cursor <cursoragent@cursor.com>
…red#2821) Isolate patch-less enrichment failures so inline patches still scan, catch per-file Contents API errors without blocking siblings, and add regression tests for the fallback paths Codecov and the gate reviewer flagged. Co-authored-by: Cursor <cursoragent@cursor.com>
…red#2821) Do not treat a failed base fetch as empty content, diff renamed files against previousFilename at baseSha, and skip truncated oversize fetches so pre-existing secrets are not mis-flagged as new leaks. Co-authored-by: Cursor <cursoragent@cursor.com>
…d#2821) Mark patch-less files over the 512KB fetch cap as incomplete and emit a secret_leak blocker instead of scanning a truncated prefix. Bound Contents API concurrency during enrichment and drop the unrelated workflow test hunk by rebasing onto main. Co-authored-by: Cursor <cursoragent@cursor.com>
…bored#2821) Mark patch-less files incomplete when Contents API fetch fails or returns partial content, instead of silently skipping header-only entries. Co-authored-by: Cursor <cursoragent@cursor.com>
…ed#2821) Exercise renamed/modified oversize paths, incomplete finding wiring, default modified status, and bounded-concurrency fan-out for Codecov patch. Co-authored-by: Cursor <cursoragent@cursor.com>
…2821) Use nullish checks for Contents API fetch results so legitimately empty added/base files are scanned instead of hard-blocked as incomplete. Fix the incomplete-finding test to assert on detail, not title. Co-authored-by: Cursor <cursoragent@cursor.com>
…red#2821) Route removed files through shouldAttemptPatchLessSecretScan and add tests for blank headSha, renamed oversize head, and multi-path incomplete findings. Co-authored-by: Cursor <cursoragent@cursor.com>
…ed#2821) When makeGithubFileFetcher or enrichment setup throws, mark eligible patch-less files incomplete instead of reverting to header-only scans. Inline patches still scan normally. Co-authored-by: Cursor <cursoragent@cursor.com>
d1f9e99 to
c1a8b22
Compare
…SONbored#2821) Export secretScanPatchFallbackInternals for direct branch tests, exercise empty-file enrichment, ineligible patch-less paths when fetcher setup fails, and shouldAttemptPatchLessSecretScan status matrix to reach the 99% patch gate. Co-authored-by: Cursor <cursoragent@cursor.com>
…ov (JSONbored#2821) Cover 512KB boundary, whitespace baseSha/previousFilename guards, helper exports, single-file concurrency, empty headSha gate skip, and webhook baseSha wiring so patch coverage clears the 99% gate. Co-authored-by: Cursor <cursoragent@cursor.com>
…2821) The mock file content trailing newline produced an extra synthetic + line and failed validate-code in CI. Co-authored-by: Cursor <cursoragent@cursor.com>
|
Gittensory is closing this pull request on the maintainer's behalf (CI is failing (codecov/patch)). This is an automated maintenance action — to pursue this change, please open a new pull request with the issues resolved. Closed PRs are re-reviewed automatically, so an inaccurate close may be reopened, but that does not guarantee it can merge (e.g. if conflicts or failing CI remain). |
…#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>
Problem
The unconditional
secret_leakhard blocker scans only+lines frombuildSecretScanDiff. GitHub omits inlinepatchfor binary/large changed files (>~1 MB), so those files produced header-only entries with no scannable body. A PR could commit a concrete credential (ghp_…,AKIA…, private key block, etc.) in a patch-less file and pass the gate.Modified patch-less files were especially invisible:
secretLeakFindingexcludes(modified)headers from its scan corpus, so even filename-based detection did not run.Root cause
buildSecretScanDiffonly includes GitHub's inlinepatchwhen present.maybeAddSecretLeakFindingnever recovered file body content for patch-less files, even though the grounding path already has a GitHub ContentsFileFetcher(makeGithubFileFetcher).Fix
When
headShais available at gate time:removed):+lines for the full file.+lines for multiset-added lines only (same "additions only" semantics as the existing diff scan).buildSecretScanDiff→secretLeakFindingpath.Fetch failures degrade to prior behavior (fail-safe; never destabilizes the gate).
Why this solution
Testing
addedLinesForSecretScanunit test (multiset line diff).enrichSecretScanFilesWithPatchFallbacktests: patch-less added file with secret →secret_leak; patch-less modified with baseSha →secret_leak; modified without baseSha → no false scan of full head.parseSlopOpinion/buildSecretScanDiff/secretLeakFindingtests unchanged.Risks
baseShastill cannot be body-scanned (unchanged conservative behavior).