Skip to content

fix(tech-detect): an inCode detector reads past strings that quote its pattern #1422 - #1485

Closed
nc9 wants to merge 1 commit into
mainfrom
fix/in-code-candidates-1422
Closed

nc9 wants to merge 1 commit into
mainfrom
fix/in-code-candidates-1422

Conversation

@nc9

@nc9 nc9 commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

Refs #1422 (the candidate limit and its test; the corpus criteria are runs over stored crawls and are not done here).

Cause, for the inCode detectors. matchesInCode inspected the first 64 matches of the pattern and gave up; each match that starts inside a string (docs text, an error message, a vendor snippet quoting a config) used one of the 64, so a whole bundle (the local scan reads up to 8 MB, against a 256 KB head) could hold more than 64 before the real config in code, which was never reached. This affects Supabase, Firebase and Clerk, the inCode detectors.

Not the cause for Contentful and Clarity. Neither is an inCode detector: Contentful is a script-url signature plus ctfassets.net in the HTML, and Clarity a script-url signature, so the 64-candidate limit never ran for them. The loss against v0.0.140 for those two is the inline-loader scoping that #1430 introduced and #1435 (v0.0.150) and the flight-payload fixes (#1437, #1477) then restored; the issue's own sites need a corpus re-run on the current head to confirm nothing is left. I could not reproduce them without the stored crawls.

  • matchesInCode: after a match that starts in a string, the search continues past that string (stringEnd, new in js-scan.ts), so many mentions inside one string are one candidate. The candidate bound is 4,096 (was 64): the matches go forward over the body once, so this bounds the work per detector (and the hostile 8 MB test stays under its budget), not correctness.
  • Tests (in-code-candidates-1422.test.ts, 5; 3 fail on main): 65 and 3,000 separate string mentions then the config in code are found; 20,000 mentions in one string then the config is found; a config only in comments and strings is still not detected; 8 MB of mentions with no real match, and one real match past the bound, finish under the time budget. The bundle-content, fingerprint, pattern-bound, local-caps, real-build, supabase-signature and extras-budget suites pass.
  • CHANGELOG under Unreleased / Fixed. No docs change (the detector behaviour is unchanged for real configs).

Review round 1: rebased onto main (the COLLECTED_TAGS import kept beside stringEnd); a test pins the boundary (the config after 4,095 string mentions is the 4,096th candidate and is found; after 4,096 or 4,097 it is not reached), direct stringEnd tests (inside, opening quote, code, past the end, and agreement with inString for every index of a mixed body), and the bundle-sample.ts comment now says the matcher's bound is 4,096. The cap is a silent miss: a config after more than 4,095 look-alike matches in strings is not found and no truncation signal says so; MAX_HIT_SCANS_PER_HINT (512 hits per hint in a capped scan) is a second silent cap of the same kind. Both are stated in the docs and the CHANGELOG; this PR adds no new behaviour for them. Stays "Refs": #1422 is not closed by this (see its comment).

Skill: no change needed.

nik

@nc9
nc9 force-pushed the fix/in-code-candidates-1422 branch from 55019d6 to 3c87b71 Compare November 1, 2026 06:13
…s pattern, up to 4,096 candidates #1422

Signed-off-by: Nik Cubrilovic <[email protected]>
@nc9

nc9 commented Nov 1, 2026

Copy link
Copy Markdown
Contributor Author

Landed in v0.0.155 as 3c4497d2 via #1503.

nik

@nc9 nc9 closed this Nov 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant