Repository navigation
feat(rules): add reliability/broken-resources and the Reliability category #703 - #714
Conversation
|
Review of #714 ( The rule is clear and well documented. It makes no new requests. Skipped fetches and unmeasured kinds are reported as partial instead of passing silently. The category wiring covers the core-contracts, rules and report mirrors, the loader, and the docs.
|
Review: reliability/broken-resources (#703)I read the diff (adapter, asset-status, resource-checker, script-fetcher, the rule, docs and tests). I did not run the test suite, and CI was still pending when I looked. The design is clean: separate
Test coverage is good: unit tests for the rule, category count updates, and an HTTP fixture test covering 404, 500, third-party, font, WAF, and the 503 split on Retry-After. I would add a test where |
Maintainer review (2026-10-12)Verdict: needs fixes (medium). Reviewed at head 07ffeb2 against main 2dca3b9. Main CI is green at that sha, so the red checks below come from this PR. Acceptance criteria (#703)8 of the 9 boxes are met.
Fixes
PR hygiene
Merge orderThis PR goes first, because it creates the |
07ffeb2 to
18bf19b
Compare
|
Review of the
|
18bf19b to
4a8b5e4
Compare
|
Review of the diff, focused on the egress guard, the asset-phase changes and the engine wiring. I did not run the tests, and CI was still pending when I looked.
The IPv6 embedding forms (mapped, NAT64, 6to4) are handled carefully. Dropping |
4a8b5e4 to
4355cd3
Compare
|
Review of #714 (
|
4355cd3 to
e15a193
Compare
|
Review of the No blocking problems found in what I read.
Tests are present for the egress guard and the rule, and the golden test is updated. I would add a case for an IPv6 |
…egory #703 A page can answer 200 while the script or stylesheet it depends on returns 404 or 500, usually because a deploy deleted the hashed bundle that cached HTML still references. No rule reported it. reliability/broken-resources reads the statuses the asset phase records, with no render: - error: a first-party script or stylesheet answers 4xx/5xx. First-party is the same registrable domain as the site (tldts, private suffixes on), plus the site host and its subdomains, so www.example.com owns example.com and cdn.example.com while a.vercel.app does not own b.vercel.app. - warn: a third-party script or stylesheet, or a font, answers 4xx/5xx, or a request fails at the network level. - info: 429, 430, 503 with Retry-After, a WAF challenge on a 403/503, or a 401/407 to the credential-less probe of a sibling first-party host is unverified, never broken. A bare 503 stays broken. - info: a fetch the budget skipped, a URL a cap dropped, a URL the egress policy refused, or an unmeasured kind makes the result partial. - one finding per resource URL, listing every referencing page. Third-party scripts, stylesheets and fonts are status-checked into a separate externalAssets field, only while the rule is enabled, capped at RESOURCE_SIZE_LIMITS.MAX_EXTERNAL_ASSETS_TO_CHECK (50) per kind and never above the caller's item cap. Those probes: - carry none of the audit's custom or Web Bot Auth headers, only User-Agent and Accept, on every request and redirect hop; - reach public addresses only, checked before every hop by the new @squirrelscan/utils/public-egress guard (resolve once and refuse private, loopback, link-local, CGNAT, reserved, multicast and metadata addresses, including IPv6 forms that embed one, and decimal/hex/octal IPv4 spellings). A site that is itself on a private network may probe private hosts, never link-local or metadata ones; - connect to the exact address that was vetted, with the original Host header and TLS server name (Bun checks the certificate against the server name), so DNS rebinding cannot move a request. The first vetted IPv4 address is tried, then the first vetted IPv6 one, only when the connection was never made (a `::1`-only localhost dev server stays reachable; nothing is re-sent). ResourceCheckOverrides.egressPinnedByTransport lets a runtime whose fetch already pins (the hosted egress proxy) vet without pinning again; - are status only: a HEAD below 400 ends the check, a GET body is never read. A refusal is recorded in the fetch budget as an answer, never a tarpit strike against the host. The same-site maps and the size, compression and script rules are unchanged. rateLimited and wafBlocked are carried on ResourceSizeData and ScriptContentData, and assetCapDropped counts referenced URLs each cap left unfetched. The budget-skip and egress-refusal placeholders are shared constants. Adds the Reliability category (group Performance) to RuleCategory, the rules and report category mirrors and the loader. Docs: a category page and a rule page under docs/rules/reliability/, the nav, the category count 21 -> 22 with a Reliability row in README.md and docs/index.mdx, and the custom-headers pages say third-party status checks never carry them. Golden gate: 101736 -> 101737 findings and 301 -> 302 tally rows (one whole-crawl check, info on the harness's empty assets); healthScore.overall stays 51. Signed-off-by: Nik Cubrilovic <[email protected]>
e15a193 to
6ccecb8
Compare
Auto-review did not completeThe
Partial findings recovered from the session (incomplete, unverified, and NOT a merge signal): Show partial reviewYou've hit your session limit · resets 10:10pm (UTC) |
Auto-review did not completeThe
Partial findings recovered from the session (incomplete, unverified, and NOT a merge signal): Show partial reviewYou've hit your session limit · resets 10:10pm (UTC) |
e212e01 to
6ccecb8
Compare
|
Review of #714: reliability/broken-resources. I read the engine, checker, egress guard and rule diffs. I did not run the tests, but CI is green (the claude-review check was still pending). I have no (high) or (critical) findings. The egress guard is careful: it vets every hop, pins the vetted address, strips credentials from third-party probes, and refuses metadata addresses even for private sites.
Test coverage: there are fixture tests for the rule and the engine, and unit tests for |
Summary
Adds the
reliability/broken-resourcesrule and thereliabilitycategory (name "Reliability", group Performance, rule prefixreliability/).The rule reads the statuses the asset phase records for every script, stylesheet and font the pages reference. It runs in HTTP-only audits and renders nothing.
www.example.comownsexample.com/app.jsandcdn.example.com/app.js, whilea.vercel.appdoes not ownb.vercel.app.Retry-After, and a WAF or bot challenge are throttling or blocking, not broken.unchecked-resourcesnote, so a pass never claims full coverage.Engine changes:
externalAssetsfield and checked by status only (HEAD first, no body stored). The same-site maps and the size, compression and script rules are unchanged.RESOURCE_SIZE_LIMITS.MAX_EXTERNAL_ASSETS_TO_CHECK(50) per kind, and never above the caller'sresourceCheckMaxItems, so an audit sends at most 150 extra requests. The cap is named in the docs, and URLs past it show in the partial note. They run only while the rule is enabled (sameisRuleEnabledcall and defaults as the runner): disable it and none are sent.Security (credential leak and SSRF on the third-party probes):
customHeaders(Web Bot Auth, Authorization, Cookie, any[crawler] headers) and the prior-crawl cache: they send squirrel'sUser-AgentandAcceptonly, on the HEAD, the GET fallback and every redirect hop. The site's own assets keep the headers (fix(engine): resolve renamed item locators on a still-failing page #474 #494), andsafeRedirectFetchstill strips them when a redirect leaves the origin.@squirrelscan/utils/public-egress:egressGuardedSendis the per-hopsendofsafeRedirectFetch, so every hop, the first included, is vetted byvetEgressTargetbefore it is sent. It refuses non-http(s) schemes; private, loopback, link-local, CGNAT, documentation, benchmarking, multicast and reserved IP literals (decimal, hex, octal and short IPv4 spellings arrive canonicalized by the URL parser and are tested); IPv6 forms that embed one (mapped, translated, NAT64, 6to4, IPv4-compatible); the cloud metadata addresses and names; non-public names (localhost,*.internal, dotless); and any name that resolves (system resolver, memoized per asset phase, failures forgotten) to no address or to any refused one.Hostheader and, over TLS, the original name astls.serverName. Measured on Bun 1.3.14: the certificate is verified againstserverName(a mismatch isERR_TLS_CERT_ALTNAME_INVALID, wildcards follow the one-label rule), directly and through a CONNECT proxy, and keep-alive TLS connections are reused only for the same server name.tls.checkServerIdentityis not relied on: Bun does not block when it returns an Error. An answer that cannot be pinned (a name, a scoped IPv6 address) is never used, and a trailing root dot is dropped from the server name. The first vetted IPv4 address is tried, then the first vetted IPv6 one, and only when the connection was never made (ConnectionRefused,FailedToOpenSocketand the other connect-phase codes): a::1-only localhost dev server (Vite on macOS) stays reachable, at most two addresses are ever tried, and a request that may have been received (a reset, a truncated answer) is never re-sent. Each redirect is resolved against the original URL, so every hop is vetted and pinned by its own name.ResourceCheckOverrides.egressPinnedByTransportlets a runtime whose fetch already resolves once and pins (the hosted egress proxy, which rewrites a plain-http Host from its absolute target) vet without pinning again; the CLI default pins. A site that is itself on a private network (localhost:3000, RFC1918, by the existingisNonPublicHostname) may probe private hosts, never link-local or metadata ones; an unknown base URL takes the strict policy. Redirect hops stay capped at 10 bysafeRedirectFetch. A refused URL is never retried and reads as "not checked", never broken.refused by the egress policy.HTTP_PROXY, a pinned plain-http probe goes out in absolute form with the address, so the proxy may answer with that address's default vhost (correctness, not reach); only the vetted address picked (IPv4 first) is tried. Two pre-existing gaps the review found (the sitemap-orphan pool sends custom headers to any host a sitemap lists; same-site pools follow a redirect to the metadata address) are tracked in squirrelscan/repo#2764.egressPinnedByTransport: truein its resource overrides, or hosted plain-http third-party probes reach the right IP with the wrong vhost.rateLimited(429/430, or 503 withRetry-After) andwafBlocked(403 or 503 with WAF headers, using the samedetectWafthe link checker uses). Only those are unverified; a bare 503 stays broken.assetCapDropped, computed byassetCapDroppedOf, unit-tested).ASSET_FETCH_SKIPPED_ERRORconstant, not a string literal in three places.Category wiring:
RuleCategoryin core-contracts, the rules and report category mirrors, the rule loader, the rules index export, and the docs rules index and nav. The category count goes from 21 to 22 in README.md, docs/index.mdx and docs/rules/index.mdx, with a Reliability row in both category tables, andreliabilityis listed in the report category filters (docs/cli/report.mdx, docs/reports.mdx).Golden gate (rebased on main 1e3842c, the 0.0.111 release, which includes pub#721):
streaming-rules-canonical-golden.test.tsmoves 101736 -> 101737 findings and 301 -> 302 tally rows. The rule adds one whole-crawl check, which is info on the harness (its empty assets carry no fonts or third-party lists), and its tally row is pinned.healthScore.overallstays 51.Agent skill: yes, the squirrelscan agent skill (squirrelscan/skills) needs a change: its SKILL.md says "300+ rules in 21 categories", and it should know the Reliability category. The maintainer files that as a private issue.
Private follow-up (not a merge blocker): hosted report ingest validates
RULE_CATEGORIESas az.enum, soreliabilitymust be added there, to the web rules slug list, and to the rule catalog in the gitlink-bump PR before the next CLI release.Closes #703
Verification
The touched packages define no format or lint script. oxfmt
--checkand oxlint (apps/cli's binaries) are clean on the new rule, egress, test and fixture files.The egress fixture tests were A/B checked: with the header strip and the egress policy removed from the probe options, the public-site, private-site-redirect and custom-header tests fail (requests reach 127.0.0.1 and the metadata address, the secret header arrives); with the per-hop guard removed from
fetchResource, the redirect test fails too. Fixture coverage: a public site's references to127.0.0.1,localhost,[::1],169.254.169.254,10.0.0.1andmetadata.google.internalsend zero requests (global fetch spy and server both see nothing); public-to-private, public-to-metadata and public-to-privately-resolving-name redirects stop before the private hop; a private site may probe127.0.0.1but its redirect to the metadata address is refused; third-party HEAD, GET fallback and redirect hops carry no custom headers while the site's own assets do; the rule disabled sends nothing; an unknown base URL is strict.Acceptance criteria
reliabilitycategory exists (name "Reliability", in the Performance group) and appears in reports, scoring and the docs rule index<script src="/app.js">where/app.jsreturns 404 produces an error finding naming the URL, the 404 status and the referencing page, in an HTTP-only audit (broken-resources-fixture.test.ts, real HTTP)Retry-After, or a WAF challenge is reported as unverified (info), never as broken (fixture test covers the WAF challenge and the 503 withRetry-After; unit tests cover 429 and 430)resourceCheckMaxItemscap drops a stylesheet, and 51 third-party scripts stop at 50 requests; both results are partial with the cap named)images/broken-imagesand are not reported twice (the rule never reads images; unit test)docs/rules/reliability/Known limits
[external_links].Checklist:
Signed-off-byline (git commit -s).