fix(rees): scan added lines whose content starts with ++ across all diff parsers#2531
Conversation
|
Warning 🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨 ⏸️ Gittensory review result - manual review recommendedReview updated: 2026-07-02 09:08:16 UTC
⏸️ Suggested Action - Manual Review Review summary Nits — 4 non-blocking
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.
|
7bbecb9 to
81e54b2
Compare
…iff parsers
Every review-enrichment diff parser guarded file headers with an unanchored
`startsWith("+++")`. git renders an added line whose content is `++x` as
`+` + `++x` = `+++x` (and `++ x` as `+++ x`), so that line was mistaken for a
`+++ b/file` header and skipped. In secret-scan.ts a secret on such a line was
never scanned (scanSecrets calls scanPatch directly).
Fixes, by parser input shape:
- Hunk-structured parsers (secret-scan, secret-log, iac-misconfig, redos,
actions-pin, eol-check, duplication-scan, shared analysis-context) track hunk
state: headers only precede the first @@, and inside a hunk the first char is
the +/-/space op, so both `+++x` and `+++ x` are scanned.
- Parsers that also accept header-only/headerless fragments (history,
heavy-dependency) use a shared isDiffFileHeaderLine helper that matches only a
real header form (`+++ b/…`/`--- a/…`/`/dev/null`), so `+++ x` content is kept
while true headers are skipped — and headerless single-line diffs still work.
- Manifest/lockfile parsers (dependency-scan, lockfile-drift) keep an anchored
`+++ ` guard; their content never begins a line with `++`.
Adds regression tests: scanPatch finds a secret on both `++x`- and `++ x`-content
lines, collectAddedLines recovers the `++x` line, and isDiffFileHeaderLine has a
unit covering headers vs `++`/`--` content and headerless diffs.
No issue because issue creation is restricted on this repo; this consolidates a
duplicated diff-parsing guard, no schema or API change.
81e54b2 to
12ec113
Compare
Summary
Every review-enrichment diff parser guarded file headers with an unanchored
startsWith("+++"). git renders an added line whose content is++xas++++x=+++x(and++ xas+++ x), so that added line was mistaken for a+++ b/fileheader and skipped. Insecret-scan.tsa secret on such a line was never scanned (scanSecretscallsscanPatchdirectly).Fix, by parser input shape:
secret-scan,secret-log,iac-misconfig,redos,actions-pin,eol-check,duplication-scan, sharedanalysis-context) track hunk state: headers only precede the first@@, and inside a hunk the first char is the+/-/space op, so both+++xand+++ xare scanned.history,heavy-dependency) use a sharedisDiffFileHeaderLinehelper matching only a real header form (+++ b/…/--- a/…//dev/null), so+++ xcontent is kept while true headers are skipped — and headerless single-line diffs still work.dependency-scan,lockfile-drift) keep an anchored+++guard; their content never begins a line with++.This is the complete follow-up to the earlier narrower attempt (which fixed only
analysis-contextand leftsecret-scan's ownscanPatch). Resolves the reviewer blockers onsecret-scan,history, andheavy-dependency(each skipped the reachable++ xcontent shape).No issue because issue creation is restricted on this repo for outside accounts; this consolidates a duplicated diff-parsing guard.
Scope
Validation
git diff --checknpm run typecheck(reestsc -p tsconfig.jsonclean)npm run test:coverage(N/A —review-enrichment/**is outside Codecov'ssrc/**/*.tsinclude)npm audit --audit-level=moderateIf any required check was skipped, explain why:
node --testpasses 391/393; the only 2 failures aretest/sentry-upload.test.ts(Sentry CLI binary absent locally), identical on unmodifiedmain. Added regressions:secret-scan.test.ts(secret on++x- and++ x-content lines),analysis-context.test.ts(collectAddedLines/filesHaveAddedLines), and adiff-lines.test.tsunit for the header discriminator.review-enrichment/**is outside Codecov'ssrc/**include. UI/workers/MCP steps are unrelated to this rees-only diff.Safety
Notes
isDiffFileHeaderLinehelper (newanalyzers/diff-lines.ts) prevents the guard from drifting again across parsers.