Repository navigation
Conversation
Signed-off-by: Nik Cubrilovic <[email protected]>
5 tasks done
…well-formed http(s) or relative values; skips counted #1539 Signed-off-by: Nik Cubrilovic <[email protected]>
…-only and unimported entries documented and pinned #1539 Signed-off-by: Nik Cubrilovic <[email protected]>
…surrogate values rejected, boundaries and quote forging pinned #1539 Signed-off-by: Nik Cubrilovic <[email protected]>
This was referenced Nov 2, 2026
Closed
nc9
added a commit
that referenced
this pull request
Nov 2, 2026
… a template for import maps #1542 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.
Closes #1539.
Reproduced on v0.0.159 (ea60499),
detectTechnologieson parts-built pages<script type="importmap">mappingthreeto jsdelivrthree.module.js./vendor/three/build/three.module.js<script type="module">import * as THREE from '<cdn>/three.module.js'<script src=...three.min.js>and<script type="module" src=...three.module.js>So the inline module case in the issue is already satisfied on main (its text is read as inline text up to 16 KB); the import map is the gap. An import map is in
DATA_SCRIPT_TYPE, so its body was never read and its URLs were never script URLs.What changes (
packages/tech-detect/src/detect.ts)In the page pass, a
<script type="importmap">is parsed as JSON and the string values of itsimportstable and of eachscopestable are kept as script URLs: one synthetic<script type="module" src="...">tag per URL goes into the markup for the URL patterns, and a collectedscriptwith thatsrcfor the tag-attribute detectors. Bounded: a map over 65,536 characters (UTF-16 code units, not bytes) is not parsed, at most 256 URLs a map and 512 a page, at most 64 KB of synthetic tags a page, at most 2,048 characters a URL. Only an http or https URL or a path starting with/,./or../is kept (a bare name and any other scheme are rejected, as browsers reject them), and a value with a quote, angle bracket, backtick, backslash, whitespace, control character (C0, DEL, C1) or lone surrogate is rejected, so each synthetic tag is exactly one well-formed script tag with the URL as itssrc(a"><script src=//evil.example/x.js>value cannot add a tag or an attribute). An entry past a bound or rejected is counted internally (pageImportMapSkipped, in no report) and not read; the rest of the page is read as usual. The map itself and its keys stay out of the markup; malformed JSON, a map withoutimportsorscopes, non-string values and other data types (JSON-LD,application/json,__NEXT_DATA__, speculation rules) are unchanged. Relative values are matched as written: resolving them against the page URL adds nothing a pattern can match (a host-anchored pattern cannot match a same-origin path, and the path patterns match./vendor/three/...as is), so AC3's resolution is not implemented; lane-review-prs to amend with the original text kept.Tests (
importmap-1539.test.ts, 41; failing first: 4 fail on main)<script type="module" src>(three.js, Tag Manager, Meta Pixel). An inline module with a static import, a namespace import andimport()of a three.module.js URL (already detected on main)."><script src=//evil-three.example/three.js>, a URL with a newline, a space,', a backtick,<,>, a backslash,javascript:,data:,blob:): no synthetic tag, one skip counted, no detection, and the markup never contains the forged host; next to a good URL the markup holds exactly one synthetic tag for it. http, https, protocol-relative and relative URLs are all kept.data-importmapattribute, JSON in aapplication/jsonscript and a map of other vendors detect nothing; CSP, anchor, JSON-LD,__NEXT_DATA__, speculation rules and prose as before.a"data-evil="1,a"/onload="1) adds no attribute; each of quote,', backtick,<,>, backslash, space, a C0 character, DEL, U+0085, U+2028, U+2029 and a lone surrogate is rejected in its own test; boundaries: map 65,536 and 65,537 characters (and 21,846 three-byte characters, read), URL 2,047, 2,048 and 2,049, 32 tags of 2,048 characters fill the 64 KB bound exactly and one character more drops the last, the 256th and 257th URL of a map;HTTPS://accepted, empty and bare values rejected, array-valuedimportsandscopesignored,importmap-shim,application/importmap+json,x-importmapandimportmapsnot read. The per-map bound is 256 (64 junk entries before the real one used to drop it). Mutants of every bound (>=and+1), each character class member, the lone-surrogate halves, the address pattern and its case flag, and the type test (contains, prefix, case) fail a test; two members that were duplicates (U+2028 and U+2029 inside\s, and the empty check inside the address pattern) were removed as equivalent.scopestable counts (scoped mappings are real); an entry the page never imports still counts (evidence, not proof); a map inside a<template>is inert and is not read (nested templates, a template closed before the map, and an uppercase tag are tested; four mutants of the depth tracking fail); a map inside<noscript>or<svg>is read as before.importmap-shimis out of scope.scopestable removed and the type test loosened tojsoneach fail a test.script-url-wrappers-1435.test.ts: the import map line is removed from its "still not read" list (a map to a clarity URL now counts, by this change).Docs (
docs/cloud/technologies.mdx) and CHANGELOG updated. No fingerprint changes, sogenerated.tsis untouched. Existing tech-detect (140 + 87 tests) and audit-engine tech tests (48) pass. Skill change: none. The corpus A/B (v0.0.159 against this head,threejsand every other detection) is for squirrelscan-53.