Repository navigation
fix(rules): noscript content, implicit ARIA roles and CSP host wildcards (#434, #435, #427) - #438
Merged
Merged
Conversation
A browser with scripting enabled parses <noscript> content as raw text, so the tracking pixels, GTM iframes and fallback stylesheets sites put there never load or render. Rules read them as live DOM and reported markup that never runs. - utils: isInsideNoscript, querySelectorAllOutsideNoscript and stripNoscriptMarkup (a linear tokenizer for the raw-source scans). - parser: image, script and stylesheet extractors skip <noscript> content; link extraction keeps it. - rules: the image, perf (incl. the shared CWV hints), sri, third-party-cookies, mixed-content, frame-title, meta-refresh and image-redundant-alt rules select through the helper. - integrity/fingerprint: the template key pins only live assets, so template-scoped rules that now skip <noscript> stay sound under fan-out. - audit-engine: blocklist URL collection skips <noscript> scripts. Signed-off-by: Nik Cubrilovic <[email protected]>
A native <input type="radio"> is a radio; the rule only accepted an explicit role="radio" and failed role=radiogroup groups of native radios. New a11y/implicit-role.ts maps native elements to their HTML-AAM roles (input types, li, tr, td/th, option, rowgroups, groups, ...). The rule now resolves each owned element's role as the first valid explicit token, else the implicit role, with presentational-role conflict resolution. It follows aria-owns (with cycle protection), skips <noscript> content, and a native wrapper (fieldset, details, optgroup, tbody) counts only through the items inside it. Signed-off-by: Nik Cubrilovic <[email protected]>
csp-wildcard used a substring match, so the * in https://*.posthog.com read as "any host". Sources are now lowercased tokens (split on whitespace and the commas of a joined policy list); csp-wildcard fires for a source whose host is a bare * (*, https://*, *:443), and keywords match case-insensitively. Signed-off-by: Nik Cubrilovic <[email protected]>
nc9
force-pushed
the
fix/rules-noscript-aria-csp
branch
from
October 1, 2026 22:41
bffbccf to
fa001d9
Compare
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 #434, #435 and #427: three rule false positives reported from real sites. Thanks to @deniskern for the reports and the exact repros, which are the fixtures below.
Changelog: Rules no longer report content inside
<noscript>as markup that loads or renders (tracking pixels, GTM iframes, fallback images and stylesheets),a11y/aria-required-childrenaccepts native elements' implicit roles such as<input type="radio">in a radiogroup, andsecurity/cspno longer calls a host wildcard likehttps://*.example.coma bare*.#434:
<noscript>content treated as live DOMCause. A browser with scripting enabled parses
<noscript>content as raw text, so nothing in it loads or renders. linkedom parses it as markup, and rules ran plainquerySelectorAllover it.Fix: one shared mechanism, applied where a rule describes what a browser loads or renders.
@squirrelscan/utils:isInsideNoscript(el)andquerySelectorAllOutsideNoscript(root, selector), plusstripNoscriptMarkup(html)for the two rules that regex the raw source (perf/js-librariesmarkers, the CWV@font-facescan). The stripper is a small linear tokenizer: comments, quoted attributes and script/style/textarea content are passed over, so a"<noscript>"in a JS string is not a tag.extractImages(both copies),extractScriptsandextractStylesheetsskip<noscript>content. That coversparsed.images(alt-text, dimensions, broken-images) and the same-domain resource fetches behind the file-size rules.extractLinksdeliberately still reads<noscript>anchors: link discovery is a crawl question.integrity/fingerprint: the template cluster key now pins only live assets. Without this, template fan-out stays unsound for the template-scoped rules above (sri, third-party-cookies, js-libraries, ...): a page whose tracker sits only in a fallback would share a key with one that loads it, and get its verdict. This was visible on the hub fixture before the change (sri still fired on the noscript page, fanned out from its template twin).Checked and kept reading
<noscript>content, with the reason:<noscript>text (content/text-content, reading-level, keyword-stuffing, hidden-text, date-agreement, unrendered-markup).<noscript>pattern in the wild puts these there.<noscript>iframe fallback), legal/*, schema/rating-scope, integrity/signals, social/share-buttons, social-profiles.<noscript>payloads in the wild are pixels, iframes and stylesheets, not these elements. Switching any of them is a one-line change if a case turns up.<noscript>meta refresh. Filed as Crawler follows a <noscript> meta refresh when resolving the seed URL #437.Evidence: the issue's repro,
squirrel audit <page> --http -m 1 -f json --refresh, CLI from sourceFindings on
noscript.htmlthatcontrol.htmldoes not have:a11y/frame-title1 iframe(s) without title attributeimages/alt-text1 image(s) missing alt textimages/responsive-size1 small image(s) may be serving oversized filesperf/critical-request-chains2 critical request chain(s) found(/noscript.css,/style.css)1 ...(/style.css), as controlperf/lcp-hints1 likely-LCP image loaded without preloadsecurity/sri1 cross-origin resource without Subresource Integritysecurity/third-party-cookies2 known tracking domain(s) detectedOn the branch the two reports differ only in page-identity items (the URL in meta-title and word-count).
control.htmlreports identical findings on main and the branch.Evidence: true positives still fire (6-page hub fixture)
The hub serves the repro, its control,
live.html(the same pixel, iframe, script and stylesheet as live markup), and an extended pair: lazy-load fallback images, a loadCSS Google Fonts fallback, a<style>with@import, a polyfill script, a LinkedIn pixel and a GTM iframe, once inside<noscript>and once live.noscript.html: the 7 rows above gone.noscript-extended.html: 15 rows gone (frame-title, alt-text, dimensions, offscreen-lazy, optimized, responsive-size, cls-hints, critical-request-chains, font-delivery, font-loading, lcp-fetchpriority, lcp-hints, preconnect, sri, third-party-cookies).live.htmlandlive-extended.html: every finding unchanged;live-extended.htmlkeeps all 15 of the rows its<noscript>twin lost, including frame-title, alt-text, sri, third-party-cookies, critical-request-chains with/noscript.css, dimensions, cls-hints, font-delivery and preconnect.#435: aria-required-children ignored implicit roles
Cause. The rule only matched
[role="radio"]for a radiogroup (and a short list of native tags for a few other roles).Fix. New
a11y/implicit-role.tsmaps native elements to their HTML-AAM / ARIA in HTML roles (input types,li,tr,td/thwith grid and scope variants,option,thead/tbody/tfoot,fieldset/details/optgroup,select,img,a[href], landmarks, ...). Each candidate's role is the first valid explicit token, else the implicit role;none/presentationis ignored on a focusable element or one with a global ARIA attribute. The rule followsaria-owns(with cycle protection) and skips<noscript>content. A native wrapper (fieldset,details,optgroup,tbody) satisfies a container only through the items inside it; an explicitrole="group"still counts on its own, as before.Evidence
/)div[role="radiogroup"]: needs child with role=radioimplicit.htmllabel > input[type=radio], tree of a barefieldsetviolations.htmlrole="menuitemradio"), tablist of buttons, menu oflidiv[role="list"]whose onlylihasrole="none"#427: csp-wildcard fired on host wildcards
Cause.
scriptSrc.includes("*")matched the*insidehttps://*.posthog.com.Fix. Sources are lowercased whole tokens, split on whitespace and on the commas of a joined policy list.
csp-wildcardfires for a source whose host is a bare*(*,https://*,*:443), which still covers every "any host" form the substring match caught; keywords match case-insensitively.Evidence (CSP set in the response header)
script-src'self' https://*.posthog.com https://*.googletagmanager.comcsp-wildcard'self' *csp-wildcardcsp-wildcard'self' https://*.example.com 'UNSAFE-INLINE' data:csp-wildcardcsp-unsafe-scripts(CSP allows 'unsafe-inline')Real-site smoke
squirrel audit https://squirrelscan.com/ -m 20 --http -f json --refreshbefore and after: identical findings, score 79, 2366 pass / 100 warn / 22 fail on both. That site has no<noscript>, no CSP header and no ARIA containers, so this is a no-change check only.Tests
packages/rules/tests/noscript-content.test.ts(94): per touched rule, the snippet inside<noscript>reports exactly what the page without it reports, and the same snippet live adds a warn/fail/info finding. Plus nested cases (picture with a<noscript>fallback img, a<noscript>WebM source), the template-key vs font-loading verdict agreement, the helpers and the stripper's tokenizer edge cases.packages/rules/tests/aria-required-children.test.ts(56),packages/rules/tests/csp.test.ts(18),packages/parser/tests/noscript-resources.test.ts(5).<noscript>case, the true-positive cases pass), 13 aria/csp cases fail, 4 of 5 parser cases fail.tsgo --noEmitclean in apps/cli, packages/rules, parser, utils, audit-engine;bun run lintandformat:checkclean in apps/cli;tangly check --strictpasses; detect-secrets clean.Docs
docs/rules/index.mdxgains a "Content inside noscript" section listing the affected rules, each affected rule page says so in "What squirrel checks", and the aria-required-children and csp pages describe the new matching, with message templates rather than filled examples.