Repository navigation
Conversation
…on static pages (#1143) New info rule and a shared payload analyzer: __NEXT_DATA__, the Next.js app router flight chunks, __NUXT__, Remix, Qwik, SvelteKit and Astro island state, sized per page with bounded reads. Reports only when the payload is at least 100 KB and 20 times the visible text on a page with at most 5 form controls and embeds and 50 buttons. Signed-off-by: Nik Cubrilovic <[email protected]>
Signed-off-by: Nik Cubrilovic <[email protected]>
nc9
force-pushed
the
feat/content-in-js-bundle-1200
branch
from
October 30, 2026 00:26
14ba8a0 to
3ee3e51
Compare
) Signed-off-by: Nik Cubrilovic <[email protected]>
nc9
force-pushed
the
feat/content-in-js-bundle-1200
branch
from
October 30, 2026 01:36
c9be9b6 to
3ebe2c6
Compare
Signed-off-by: Nik Cubrilovic <[email protected]>
…to a JS chunk (#1200) Page-time sentences from each page's main content, searched for in the site's same-origin chunks of 50 KB or more after decoding JS escapes, entities and whitespace. A chunk with a loading page's own content warns; one with at least two other pages' content fails. Bounded: 8 MB per chunk, 10 chunks, 300 pages, 2.5 s. Signed-off-by: Nik Cubrilovic <[email protected]>
Signed-off-by: Nik Cubrilovic <[email protected]>
#1200) The entity and \u{ lookaheads scanned to the end of the chunk when no terminator existed (quadratic on a chunk of '&'). Decode into a preallocated buffer with fixed lookahead, find every needle in one rolling-hash pass with a verification cap and a deadline, cap text-node and candidate reads, and add adversarial tests. Signed-off-by: Nik Cubrilovic <[email protected]>
…ecked reporting, info for one page (#1200) Walk only outermost landmarks and dedupe sentences before picking five. Skip browser-rendered pages. Report a verification-cap stop for what it is, never report a clean pass when chunks were not fetched, cap severity at warn (info for a single page's copy, from a 36-site run), yield between chunks and lower the default page cap to 2000. Signed-off-by: Nik Cubrilovic <[email protected]>
nc9
force-pushed
the
feat/content-in-js-bundle-1200
branch
from
October 30, 2026 02:58
3ebe2c6 to
63f3594
Compare
This was referenced Oct 30, 2026
nc9
added a commit
that referenced
this pull request
Oct 30, 2026
…ntBody test) and oxfmt of the content store Signed-off-by: Nik Cubrilovic <[email protected]>
Contributor
Author
|
Landed in v0.0.143 as nik |
nc9
added a commit
that referenced
this pull request
Nov 5, 2026
…s() #1307 Signed-off-by: Nik Cubrilovic <[email protected]>
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 #1200.
Depends on #1304 (PR1, #1143). This branch contains the PR1 commit so it builds and tests on its own; the diff shows PR1's files until #1304 merges, then I rebase onto main and the diff is only the second commit (
14ba8a08). Target is main, not the PR1 branch, so the squash-merge of PR1 cannot close this PR.What
New site-scope rule
perf/content-in-js-bundle: a same-origin JavaScript chunk (50 KB or more) that contains the text of the site's pages (compiled MDX or Markdown bodies, inlined CMS JSON), so the content downloads twice.shared/content-in-script.ts(extends PR1's shared analyzer set):extractContentSentences(doc)keeps up to 5 distinctive sentences per page (single text nodes of 10+ words, longest first, frommain/article/[role=main]or the body outside nav/header/footer/aside/form; code blocks skipped);normalizeScriptTextdecodes a chunk once (JS escapes\" \' \n \t \xNN \uNNNN \u{N}, entities named/decimal/hex, whitespace collapse) in one linear pass;countSentencesIn;estimateProseShare;gzipSize(CompressionStream, only for flagged chunks).CollectedPageSignal.contentSentences(bounded: 5 x 200 chars), built while the DOM is live; v1 readssite.pagesdocuments. A crawl whose records predate the field reportsskipped, not clean.min_sentences). Sentences that open 3+ pages' main content are template text and dropped. Chunk with a loading page's own content: warningcontent-in-js-bundle. Also holds at least 2 other pages' content (escalate_other_pages): failurecontent-in-js-bundle-sitewide. Items give chunk URL, size, gzip size, pages with content, other pages, estimated prose share.ctx.site.scripts, decoded once per audit, same 5 MB / timeout limits). Further bounds: chunk text over 8 MB is reported as not searched, 10 largest chunks, 300 pages per chunk (loading pages first, then an even sample), 2.5 s wall-clock for the whole search (reports partial). Measured: normalising 5 MB takes about 33 ms and 1500 absent needles against it about 300 ms.Four-file recipe and counts
Rule + registry (
performance/index.ts), docs pagedocs/rules/perf/content-in-js-bundle.mdx+docs.jsonnav + generated hub table, perf count 31 to 32 (docs/rules/index.mdx,docs/rules/performance/index.mdx),constants.tscomment 311 to 312 (PUBLIC_RULE_COUNT_FLOOR300 unchanged), canonical golden:perRuleTally315 to 316 and findings +1 (103744 to 103745: the fixture has no chunk large enough, so one pass check), CHANGELOG bullet under Unreleased. A site rule needs notemplate-invariance-measured.jsonentry (rule-verdict-scope passes).PRIVATE follow-up at release (not done here): regenerate the rule catalog, bump
totalRulesinapps/web/src/components/rules.tsx, bump the gitlink. Total rule count after PR1 and PR2: previous + 2.Tests
packages/rules/tests/content-in-js-bundle-1200.test.ts(40): sentence extraction (chrome excluded, short text, inline-split text, code blocks, 60k-node page bounded); decoder per escape form (JSX/JS quotes,\n/\t/line continuation,\u\u{}\x, named/numeric entities, unknown sequences, over-cap); prose share; and for BOTH engines (resident and streaming collected signals): own content flagged with chunk, sizes and prose share; sitewide escalation counting other pages; match through quotes,\n/\t,\u, entities (one test each); hydration-only negative; chunk under 50 KB; nav/footer-only text; template text; unfetched chunk; huge chunk bounded and reported; 400 pages x 1.5 MB chunk within the cap; no scripts; old records skipped.Verified / not
Verified: tsgo (rules),
make validate, the new test, rule-verdict-scope, template-verdict-page-independence, template-verdict-inputs, docs-category-table, meta-string-limits, docs-rule-pages, the canonical golden, streaming-collector/pre-rules/template-cluster-key goldens, rule-time-budget, ws4-rule-batches. A realsquirrel audit(dev entry,--offline --http) of a local 8-page site whose 110 KB entry chunk holds every page's compiled text reports the sitewide failure through the streaming engine with the chunk URL, size and all 9 pages (the fixture serves/and/p0.htmlas two pages). Not verified: the fullscripts/test-suites.ts --run rulessuite (left to CI), a smoke run over real MDX-on-Vite sites (none to hand; fixtures are synthetic), and gzip size in the cloud runtime (CompressionStream is used where present, omitted otherwise).AC check: matching through JSX-escaped quotes,
\n/\uescapes and entities has a test each; fetching reuses the existing script fetch; the bounded-chunk test is above.Skill: no change needed.
Caps on untrusted input (scan follow-up: "denial-of-service in content-in-script.ts")
An automated scan flagged this file. Review found one real quadratic: the entity decode did
indexOf(";")and the\u{decodeindexOf("}")from every&or\u{, each scanning to the end of the chunk when no terminator exists, so 5 MB of&was about 25 trillion steps. Fixed inc9be9b67:normalizeScriptText): one pass, fixed lookahead (an entity is looked for within 10 characters,\u{hex within 8 digits), output into one preallocatedUint16Array(2 bytes per input character, no per-escape string allocation), chunks over 8 MB of text refused unread. No regex runs over a chunk.findNeedles): replaces oneincludesper needle per page (worst case O(chunk x needle length) each, and one call per page) with ONE pass using a rolling hash of 24-character windows against the needles' prefix hashes. Time is O(chunk) regardless of the number of pages or sentences; a hash hit is verified withstartsWithat most 100,000 times per chunk, so a haystack or a needle set built to collide cannot force more; exits early when every needle is found; checks a deadline every 65,536 positions.max_pages_checked, hard max 20,000), 2.5 s wall-clock for the whole search with a visible partial note, prose-share estimate linear.tests/content-in-script-adversarial-1200.test.ts(22): decoder on 5 MB of&,&#,\u{,\u{abcdef, backslashes, escape runs, quote/escape alternation, brackets, whitespace and astral entities (ceiling 4 s, observed tens of ms), a doubling test (4x input must stay under 10x time, best of three) that a quadratic decoder fails, counters for the matcher (positions never exceed the haystack, 0 verifications for 25,000 non-matching needles, verifications capped at 100,000 for a prefix-repeating haystack and for 20,000 needles sharing a prefix, early exit, past deadline stops within the first check), extraction of a 5 MB text node, 200,000 sibling nodes, 3,000-deep nesting and 20,000 paragraphs, and the rule over 200 chunks of 100 KB. Run three times locally with no flake; the structural limits use counters, only the ceilings use the clock.Review round (g6)
main/article/[role=main]are walked and identical sentences are deduped before the top five, so<main><article>keeps its five (test).content-in-js-bundle-uncheckedcheck and never a clean pass; the docs no longer present the 8 MB decode limit as reachable (the 5 MB fetch cap comes first; 8 MB is a backstop).max_pages_checkedis now 2,000 (max 20,000).documentBodyis used here and covers the empty-document case; fix(parser,rules): empty-body pages and hostile ids no longer throw rule errors #1270 #1276 #1290 fixes the same class at the parser root for the other rules.