Repository navigation
Conversation
…coded page, not the Content-Length #1497 Signed-off-by: Nik Cubrilovic <[email protected]>
nc9
force-pushed
the
fix/parse-cap-decoded-size
branch
from
November 1, 2026 05:59
ba75013 to
4c2a0e4
Compare
This was referenced Nov 1, 2026
Merged
…ts (CodeQL js/incomplete-url-substring-sanitization) #1497 Signed-off-by: Nik Cubrilovic <[email protected]>
Contributor
Author
|
Landed in v0.0.155 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.
Closes #1497.
The
--max-durationcap (5 MiB, because a parse cannot be interrupted) compared the recordedsizeBytes, the Content-Length header, which is the encoded size. A gzip response of a few KB that inflates past the cap was parsed in full. Same wire size in three places, all fixed:crawler.tsparse gate,adapter.tsbuildSiteContext, andstreaming.ts(the pass that counts and lists the pages left out) now usedecodedPageBytes(sizeBytes, body)(new,@squirrelscan/utils/bytes): the larger of the recorded size and the body's UTF-8 bytes. Exact (Buffer.byteLength, no allocation), and only evaluated when a cap is set.sizeBytesstays the reported transfer size.parse-cap-decoded-size.test.ts(crawler throughcrawler.start(), 4 tests; the gzip and the multi-byte cases fail on main, the plain-over-cap and under-cap cases pass on both),site-context-parse-cap-1332.test.ts(an inflated page recorded at its encoded size is left unparsed) andstreaming-parse-cap-decoded-1332.test.ts(3 tests; the first fails on main: the page is counted inpagesTooLargeand listed). The existingmax-durationtests pass. The large-page e2e (audit-max-duration-large-page-1332-e2e) needs a quiet runner: it passes at a load of 11 to 17 with a margin of about 0.5 s at +10 CPU hogs, and timed out at a load of about 50 here with and without this change, so it is not evidence either way.docs/cli/audit.mdx(the 5 MiB is the decoded size) and CHANGELOG under Unreleased / Fixed. tsgo is clean for the three packages.Review round 1: boundary tests (a decoded page of exactly the cap parses, one byte more does not) in the crawler gate (plain and gzip),
buildSiteContextand the streaming guard, which kill the>to>=mutants at all three sites; multi-byte cases (30,000 three-byte characters, under the cap in characters and over it in bytes) inbuildSiteContextand the streaming test. Thebytes.tscomments say a response with no Content-Length is sized from its body (so the multi-byte gap before this change was gzip only) and that current Bun counts a lone surrogate as 3 bytes.Skill: no change needed.
nik