Skip to content

fix(cli): squirrel audit --offline checks nothing on another site #807 - #816

Merged
nc9 merged 4 commits into
mainfrom
fix/offline-third-party-807
Oct 15, 2026
Merged

nc9 merged 4 commits into
mainfrom
fix/offline-third-party-807

Conversation

@nc9

@nc9 nc9 commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Closes #807.

What changes

squirrel audit --offline is documented to leave out cloud features and checks of other sites. The asset phase still status-checked two kinds of URL on other hosts:

ResourceCheckOverrides gains ownSiteOnly, and the CLI sets it for --offline. With it set:

  • the third-party probes do not run, so externalAssets is absent and reliability/broken-resources reports "third-party resources were not measured this audit" in its unchecked-resources note, with no broken-resources row. When the pages reference no third-party resource at all, externalAssets is empty instead, so nothing reads as unmeasured;
  • a sitemap URL on another site gets no status check, and is dropped before the status cap so it takes no own-site URL's slot. crawl/sitemap-4xx says how many it skipped on a new info row, sitemap-off-site-not-checked ("{count} sitemap URL(s) on another site not checked this audit"), instead of a silent pass; when every URL to check was off-site, sitemap-4xx itself is skipped ("No sitemap URL on the audited site to check"), not passed. The count travels as an optional sitemapOffSiteSkipped on the site data, set by the asset phase and carried by both rule runners.

The audited site's own assets, subdomains included, and the internal link check are unchanged. External links were already off under --offline.

What --offline still does not cover

Requests to the audited site can still end up on another host when the site sends them there: a page or asset redirect (the soft-404 confirmation re-fetch included), or a sitemap file that robots.txt lists on another host. The copy (CHANGELOG, cli/audit, the --offline help text and completions) says so rather than promising zero off-site requests. Holding those hops to the site, and one definition of "own site" for assets and sitemap URLs, is #819. A related custom-header leak across the soft-404 confirmation's redirect, not specific to --offline, is #820.

Tests

  • apps/cli/tests/commands/audit-offline-third-party-wiring.test.ts runs squirrel audit https://example.com/ --offline through citty's real parser, with a stubbed fetch. The page loads a stylesheet and a script from third-party hosts. No request reaches them, checked by URL and by Host header, since a pinned request carries the name in Host. Fails on main.
  • packages/audit-engine/tests/offline-own-site-only-807.test.ts makes no network request: the third-party references and the off-site sitemap URL are on .invalid, refused on the URL alone. It runs the asset phase, then the rules through the real runners.
    • The control: a normal run lists both third-party references and status-checks the off-site sitemap URL.
    • With ownSiteOnly: no third-party probe, reliability/broken-resources says they were not measured and emits no broken-resources row; pages with no third-party reference get an empty externalAssets and no such note.
    • With ownSiteOnly, through both runRulesOnStorage and runStreamingRules: the off-site sitemap URL is not checked, and crawl/sitemap-4xx is skipped with the info row. Removing the threading line from either runner fails its case (checked).
  • packages/rules/tests/sitemap-4xx-off-site-807.test.ts: the info row beside a pass, the skip when every URL was off-site, the unchanged pass with nothing skipped, and no row at 0 or absent.

Also re-run: rate-limited-links, asset-egress-2764, self/completion. tsgo is clean for rules, the engine and the CLI; oxfmt/oxlint pass on the changed CLI file; tangly check --strict passes.

Docs and skill

  • cli/audit says what --offline leaves out, and what it does not hold back.
  • rules/reliability/broken-resources notes the offline case; rules/crawl/sitemap-4xx documents the skip and the new info row.
  • CHANGELOG has an entry under Fixed.
  • The squirrelscan agent skill needs no change.

@nc9
nc9 force-pushed the fix/offline-third-party-807 branch from 0fd46e9 to 5cede7d Compare October 15, 2026 13:21
@nc9 nc9 changed the title fix(cli): squirrel audit --offline sends nothing to a third-party host #807 fix(cli): squirrel audit --offline checks nothing on another site #807 Oct 15, 2026
@nc9
nc9 marked this pull request as ready for review October 15, 2026 13:31
@claude

claude Bot commented Oct 15, 2026

Copy link
Copy Markdown

Review of #816 (--offline skips status checks on other sites).

I read the diff and the surrounding adapter.ts scope. I did not run the tests.

  • (nit) packages/audit-engine/src/adapter.ts ~L1485: the empty externalAssets branch counts externalScripts.size + externalCss.size + externalFonts.size === 0 inline. A small named boolean would read better. Behaviour looks correct.
  • (nit) sitemap-4xx reports the skipped case as skipped with an extra info row. That is sensible. The row name sitemap-off-site-not-checked is documented, so the docs and rule agree.
  • (low) The wiring test relies on example.org and example.net resolving, so it passes by absence. The engine test uses .invalid and is the stronger guard. Consider asserting in the wiring test that the fetch stub saw no non-example.com host at all, not only those two suffixes.

Correctness: isOwnSiteUrl is in scope at the sitemap filter. Off-site URLs are dropped before the cap, so they take no slots. sitemapOffSiteSkipped is passed through both the v1 and streaming runners. The CHANGELOG, docs and shell completions are updated. Test coverage is good: unit tests for the rule, engine tests for both runners, and a CLI wiring test.

No blocking issues.

nc9 added 4 commits October 16, 2026 00:57
…#807

The asset phase status-checked third-party scripts, stylesheets and
fonts (reliability/broken-resources) and sitemap URLs on other hosts
whatever --offline said: the probe was gated only on the rule. A new
ResourceCheckOverrides.ownSiteOnly, set by --offline, skips both; the
rule reads third-party resources as not measured.

Signed-off-by: Nik Cubrilovic <[email protected]>
…e run skipped #807

Review round 1: the --offline copy no longer claims zero off-site requests
(redirects and robots.txt sitemaps on another host still reach it), the
skipped off-site sitemap URLs get an info row instead of a silent pass, and
pages with no third-party reference no longer read as unmeasured.

Signed-off-by: Nik Cubrilovic <[email protected]>
…s when all were off-site #807

Review round 2: off-site sitemap URLs are dropped before the status cap under
--offline, so they cost own-site URLs no slot and the count is complete;
sitemap-4xx is skipped rather than passed when every URL was off-site; copy
says 'another site' and names page and asset redirects; completions match the
help text; the engine test drives both rule runners.

Signed-off-by: Nik Cubrilovic <[email protected]>
…807

CodeQL js/incomplete-url-substring-sanitization: a bare endsWith('example.org')
also matches notexample.org.

Signed-off-by: Nik Cubrilovic <[email protected]>
@nc9
nc9 force-pushed the fix/offline-third-party-807 branch from f9f1890 to 2674c0e Compare October 15, 2026 13:58
@claude

claude Bot commented Oct 15, 2026

Copy link
Copy Markdown

Review of #816 (--offline skips third-party asset and off-site sitemap checks).

I read the diff and did not run the tests. I found no blocking problems. The change is small and gated on ownSiteOnly, so normal audits behave as before.

  • (nit) packages/audit-engine/src/adapter.ts: sitemapOffSiteSkipped counts every off-site candidate before the cap is applied. That is the right number to report, but a short comment saying so would help. It is easy to mistake for the count of URLs dropped by the cap.
  • (nit) The externalAssets: { scripts: [], css: [], fonts: [] } branch for "no third-party references" is nested inside a ternary. Pulling it into a named const would be easier to read.
  • (low) The wiring test uses example.org and example.net, which resolve. If the ownSiteOnly wiring regresses, the test still fails correctly because the stubbed fetch records the hosts. Redirects to another host are documented as out of scope, so there is no test for them. That is fine as long as the docs stay accurate.

Tests cover both runners (v1 and streaming), the control case, the no-third-party-reference case and the rule's skipped/info rows. The docs, changelog and shell completions are updated to match.

@nc9
nc9 merged commit 7be2e21 into main Oct 15, 2026
15 checks passed
@nc9
nc9 deleted the fix/offline-third-party-807 branch October 15, 2026 14:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

squirrel audit --offline still status-checks third-party scripts, stylesheets and fonts

2 participants