Repository navigation
Conversation
… truncation, linear comment scan, per-script cap kept for other callers #1387 Signed-off-by: Nik Cubrilovic <[email protected]>
nc9
force-pushed
the
feat/tech-detect-caps-1387
branch
from
October 31, 2026 00:41
0cb7bda to
093b15a
Compare
This was referenced Oct 31, 2026
Closed
Merged
Contributor
Author
|
Landed in v0.0.147 as nik |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1387.
The local tech scan now reads each first-party bundle whole, says when a cap or the time budget cut it short, and no constant sits below the configured cap.
Limits (local scan / cloud payload)
[tech_detect] bundle_bytessets both; schema max 16 MiB, was 256 KB).TECH_SCRIPT_CONTENT_LIMIT(the hard 256 KB slice in detect.ts) is gone.MAX_IN_CODE_CANDIDATES8 to 64. Sampler scan limit 6 MB to 32 MB.localTechBundleLimitsis new,techBundleLimitsis unchanged. When every body fits whole,buildTechInputsskips the floor and sampling passes (no second scan of the text).Truncation report.
ReportTechnologies.truncated?: { reasons: ("bundle-bytes" | "page-bytes" | "audit-bytes" | "time-budget")[]; scripts: number }, set bybuildTechInputs(byte caps) anddetectReportTechnologiesMulti(time budget viaonBudgetExceeded). JSON carries it; text, markdown, console and html show a note beside the list throughtechChangeSummary; llm and xml carry atruncated="..."attribute. Absent when everything was read. Limitation:detectLocalTechnologiesstill returns null when nothing is detected (so a weak local result never clears synced tech), so a truncated scan with zero items says nothing; and a cloud-detected section does not carry the field.CPU: the real finding. With the 256 KB slice gone,
scanJs(the comment/string scanner under everyinCodedetector) went quadratic on a body of many/*openers:indexOf("\0")ran to the end of the file for every comment (400 KB of/*took 0.9 s, the existing 3.9 MB adversarial body took 97 s). It now finds the next NUL once. Measured after the fix: the adversarial body detects in 281 ms across all fingerprints (supabase 40, firebase 35, clerk 35 ms); a 5 MB+ hostile body end to end (inputs plus detection) is under a second; 6 scripts x 5 MB benign takes 1.3 s and 157 MB RSS, 60 x 1 MB takes 1.9 s (page cap leaves 30 out, reported aspage-bytes), 3 x 8 MB 1.3 s and 254 MB. The #1380 sampler (windows tested against detector patterns) only runs for a body overbundle_bytes; its 5 MB hostile test is unchanged. Detections before/after on the supabase/firebase/clerk real-build fixtures are unchanged (1254 and 1379 suites pass).Tests:
tech-local-caps-1387.test.ts(9: fingerprint 1.5 MB into a 2 MB bundle at the local defaults, 8 MB bundle whole, cloud caps unchanged, bundle/page/audit/time truncation reasons, no field when whole, hostile 5 MB inside the budget), reporttechnologies-truncated-1387.test.ts(5), clitech-detect-local-limits-1387.test.ts(3), config max (16 MiB), tech-detect (whole body wherever the call sits; 8 MB of/*in linear time). Gates: tech-detect, audit-engine tech, config, report tests (307), tsgo in tech-detect, audit-engine, config, report, core-contracts and apps/cli, cli format:check and lint,make validate, released-changelog guard. The pattern-bounds suite flakes under load (passes alone).Docs:
docs/cloud/technologies.mdx(limits table, truncated, config range). CHANGELOG under Unreleased / Changed. Skill: it needs a change (it still saysbundle_bytesis 0 to 262144): private issue squirrelscan/repo#3698 (labelskills).nik
Review round (one squashed commit, no wip commit)
scanJsno longer goes quadratic on NUL-split unterminated comments: the next*/is memoised like the next NUL ("/*\0".repeat(n)was 14 s at 1 MB). New tests cover closed, open and NUL-split openers with and without a closer, and NUL-split line comments, at 1 MB and 8 MB, with a tight bound (2 s for the scan, not the page budget); the NUL shape fails at 22 s without the fix.DetectOptions.maxScriptCharsdefaults toTECH_SCRIPT_CONTENT_LIMIT(256 KB) again, so the cloud services and any future gitlink bump keep their cost bound. Only the local scan passesLOCAL_TECH_DETECT_OPTIONS(16 MiB script limit, 30 s page budget). Tested both ways.truncatedfor what the payload caps cut (techInputTruncation), documented; merging the local scan into it is tech-detect: merge the local whole-bundle scan into the signed-in cloud technologies section #1406 (not in this PR).sentryno longer fires on supabase-js (it quotesSentry.init()in prose at 226 KB): the pattern is/\[Sentry\]|Sentry\.init\(\s*\{/; a built supabase-js bundle is a negative test, and real init calls and the SDK log prefix still detect.truncatedandsourceare inoutput.mdx;meta.schemaVersionis 1.3 (it will conflict with feat(report): --include-pages rows carry finalUrl and outcome #1260 #1397's 1.2 line inlimits.tsand the e2e/report tests: whichever merges second takes 1.3).truncated/source, accepts 1.2 and 1.3), #3698 (skill text).