Skip to content

fix(queue): scan patch-less copied/changed/unchanged files for secret scan - #5951

Merged
loopover-orb[bot] merged 1 commit into
JSONbored:mainfrom
andriypolanski:fix-patchless-secret-scan-copied-changed-5947
Jul 15, 2026
Merged

fix(queue): scan patch-less copied/changed/unchanged files for secret scan#5951
loopover-orb[bot] merged 1 commit into
JSONbored:mainfrom
andriypolanski:fix-patchless-secret-scan-copied-changed-5947

Conversation

@andriypolanski

Copy link
Copy Markdown
Contributor

Closes #5947

PR body

Summary

shouldAttemptPatchLessSecretScan silently treated GitHub PR file statuses
copied, changed, and unchanged as "never scan" — identical to removed
even though those statuses can carry committed content. A patch-less file with
one of those statuses was neither enriched via the content-fetch fallback nor
marked secretScanIncomplete, so it contributed zero content to the
secret_leak hard blocker with no fail-closed advisory either. That contradicts
this module's documented guarantee.

Root cause

GitHub's diff_entry status is added | removed | modified | renamed | copied | changed | unchanged. The function handled the first four and fell through to
return status === "added" for everything else, which is always false for
the remaining three. Downstream (maybeAddSecretLeakFinding
enrichSecretScanFilesWithPatchFallbackbuildSecretScanDiff) only marks
incomplete for files that were attempted and exceeded the size cap — so a
never-attempted file was silently dropped from both the scan and the advisory.

Change

  • src/queue/patchless-secret-scan.ts
    • Treat copied, changed, and unchanged like modified: attempt the
      base/head multiset scan when baseSha is present.
    • For unchanged, chose defense-in-depth attempt-when-baseSha (option a)
      rather than unconditional incomplete: matching modified keeps the scan
      cheap when content truly matches (addedLines.length === 0), while still
      covering merge-commit contexts where content can differ. Fail-closed still
      applies if the fetch/size-cap path marks incomplete.
    • removed and renamed branches unchanged. Constants unchanged. Existing
      enrich path already treats non-added/non-renamed statuses as
      modified-style once shouldAttempt returns true — no enrich rewrite needed.
    • Module docstring updated so the fail-closed guarantee lists these statuses.

Tests (test/unit/patchless-secret-scan.test.ts)

  • Updated the pinned status === "copied" assertion (now true with baseSha;
    also covers null/blank baseSha → false).
  • New assertions for changed and unchanged (with/without baseSha) plus an
    unknown-status → false branch.
  • it.each enrichment regressions: copied/changed/unchanged patch-less
    files with a committed secret synthesize a scan patch and fire secret_leak;
    without baseSha they stay unscanned (no silent incomplete either — same as
    modified).
  • maybeAddSecretLeakFinding end-to-end: a patch-less copied-status file
    with a real ghp_ token is flagged secret_leak, not silently dropped and
    not marked "could not be fully scanned".
  • Fetch-cost wiring asserts copied/changed/unchanged cost 2 fetches when
    eligible (0 when not).

Coverage on src/queue/patchless-secret-scan.ts: 100% statements / branches /
functions / lines
.

Links

@andriypolanski
andriypolanski marked this pull request as draft July 14, 2026 23:48
@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 gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier. gittensor:priority Maintainer-selected Gittensor priority — scores a 1.5x multiplier. labels Jul 14, 2026
@loopover-orb

loopover-orb Bot commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Tip

🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩

✅ LoopOver review result - approve/merge recommended

Review updated: 2026-07-15 04:58:50 UTC

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

✅ Suggested Action - Approve/Merge

  • safe to merge

Review summary
This closes #5947 by extending shouldAttemptPatchLessSecretScan to treat GitHub's copied/changed/unchanged diff statuses like modified (attempt scan when baseSha is present) instead of silently falling through to false. The restructured if-chain is logically sound (unknown statuses now explicitly return false, matching the new test case), and the PR backs the claim that no enrich-path rewrite is needed with tests that actually exercise enrichSecretScanFilesWithPatchFallback and maybeAddSecretLeakFinding for the new statuses and assert a real secret_leak finding is produced. The unchanged-status defense-in-depth choice (attempt-when-baseSha rather than unconditional-incomplete) is reasoned and documented inline, and the docstring/module comments were updated to reflect the new guarantee.

Nits — 4 non-blocking
  • Only the `copied` status gets a full maybeAddSecretLeakFinding integration test (patchless-secret-scan.test.ts ~line 1215); `changed`/`unchanged` are covered only at the shouldAttempt/enrich unit level, so end-to-end wiring for those two isn't directly exercised.
  • The inline comment block added at src/queue/patchless-secret-scan.ts's shouldAttemptPatchLessSecretScan is quite long for a single branch; consider trimming to the load-bearing rationale (why unchanged is still attempted) and moving the GitHub schema citation to the module docstring where it now duplicates similar text.
  • Add one maybeAddSecretLeakFinding-level test for `changed` or `unchanged` (not just `copied`) to directly prove the full pipeline wiring for all three statuses, not just the shouldAttempt/enrich unit boundary.
  • Since `copied` files can have a base path different from the head path, consider a short comment or test noting the expected behavior when the multiset diff against `baseSha` finds no content at the given path (i.e., confirm it scans as fully-new rather than being skipped).
Signal Result Evidence
Code review ✅ No blockers 1 reviewer
Linked issue ✅ Linked #5947
Related work ⚠️ 2 scoped overlaps Top overlaps are listed below; lower-confidence bulk is hidden.
Change scope ❌ 8/20 High review scope from cached public metadata (1 linked issue).
Validation posture ✅ 25/25 PR body includes validation/test evidence.
Contributor workload ✅ 10/10 Author activity: 198 registered-repo PR(s), 117 merged, 25 issue(s).
Contributor context ✅ Confirmed Gittensor contributor andriypolanski; Gittensor profile; 198 PR(s), 25 issue(s).
Gate result ✅ Passing No configured blocker found.
Improvement ✅ Minor risk: clean · value: minor · LLM: moderate
Review context
Contributor next steps
  • Start here: Review top overlaps.
  • Then work through the remaining 2 steps in the Signals table above.
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.
🧪 Chat with LoopOver

Ask LoopOver a question about this PR directly in a comment — grounded only in the same cached, public-safe facts shown above, never a new claim.

  • @loopover ask <question> answers contribution-quality Q&A with source citations and freshness.
  • @loopover chat <question> answers in natural prose from cached decision-pack facts via local inference (maintainer/collaborator; read-only).
  • A plain-language @loopover mention with a real question is routed to the closest matching read-only command automatically — no exact syntax required.

Full command reference: https://gittensory.aethereal.dev/docs/loopover-commands

🧪 Experimental — new and may change.

🟩 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 LoopOver, a quiet PR intelligence layer for OSS maintainers.

  • Re-run LoopOver review

@codecov

codecov Bot commented Jul 15, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.16%. Comparing base (de3a0de) to head (8ec5025).
⚠️ Report is 7 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #5951   +/-   ##
=======================================
  Coverage   95.16%   95.16%           
=======================================
  Files         589      589           
  Lines       46768    46779   +11     
  Branches    14933    14936    +3     
=======================================
+ Hits        44506    44517   +11     
  Misses       1511     1511           
  Partials      751      751           
Flag Coverage Δ
shard-1 43.49% <100.00%> (-0.40%) ⬇️
shard-2 36.34% <20.00%> (+0.14%) ⬆️
shard-3 31.96% <0.00%> (+0.09%) ⬆️
shard-4 31.96% <0.00%> (+0.14%) ⬆️
shard-5 32.26% <0.00%> (-0.33%) ⬇️
shard-6 44.89% <0.00%> (+0.34%) ⬆️

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

Files with missing lines Coverage Δ
src/queue/patchless-secret-scan.ts 100.00% <100.00%> (ø)

@JSONbored
JSONbored force-pushed the fix-patchless-secret-scan-copied-changed-5947 branch from f2b69fe to 8ec5025 Compare July 15, 2026 04:51
@JSONbored
JSONbored marked this pull request as ready for review July 15, 2026 04:51

@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.

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

@loopover-orb
loopover-orb Bot merged commit 49883fa into JSONbored:main Jul 15, 2026
15 checks passed
This was referenced Jul 15, 2026
@andriypolanski
andriypolanski deleted the fix-patchless-secret-scan-copied-changed-5947 branch July 16, 2026 15:10
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. gittensor:priority Maintainer-selected Gittensor priority — scores a 1.5x multiplier.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(queue): shouldAttemptPatchLessSecretScan silently skips copied/changed/unchanged file statuses, bypassing the fail-closed secret scan guarantee

3 participants