Skip to content

fix(engine): a private site's link checks stay out of the shared cache; the bulk checker gets public links only #775 - #802

Merged
nc9 merged 3 commits into
mainfrom
fix/link-cache-egress-775
Oct 15, 2026
Merged

nc9 merged 3 commits into
mainfrom
fix/link-cache-egress-775

Conversation

@nc9

@nc9 nc9 commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Closes #775.

What changes

1. The shared link cache holds only public-only checks. The CLI's external link cache is shared by every audit on the machine. An audit of a site on a private network allows private addresses, so it cached verdicts for public names that resolve privately, and for redirect chains it followed into private hosts. A later public site's audit could be answered from that cache: refusedWithoutLookup only settles what the URL itself says, so a public name that resolves privately passes it.

  • checkExternalLinks now reads and writes the cache only when its egress policy is public-only (isPublicOnlyEgress: no allowPrivateNetwork, allowPrivateTarget, trustTarget or allowHost). A private site's audit checks every link afresh and caches nothing.
  • The CLI cache gets a public_only column. Every row this version writes sets it, and reads require it. Rows written by earlier versions are ignored until the next check of the link replaces them. That drops any verdict a private site's audit cached before this change, and any cloud refusal cached as a broken link (point 3). The cost: each link is checked again once after the update.

2. The bulk checker only gets public links. The cloud dead-links check is a public service. It is never sent a link whose URL names a non-public host (refusedWithoutLookup under the strict public policy: a private or loopback address, localhost, a .local or other internal zone, a single-label name), whatever the audit's policy. Those links take the local check, which a private site's audit is allowed to make. A batch made only of such links does not call the service at all.

3. A cloud refusal is not a verdict. When the service answers a link it will not request (the link, or a redirect it leads to, is on a non-public address) with status: null, error: "blocked_non_public_host:<reason>", the engine used to record that error as the link's answer: reported broken, and cached. Now such a link takes the local check:

  • On a public site's audit, a name that resolves privately is refused there (refused, never broken, not cached). A redirect into a private host stops at the redirect.
  • On a private site's audit, the local check reaches it.
  • Any other bulk error is still the link's answer.

Tests

All new tests fail on main, checked by swapping in main's file.

packages/audit-engine/tests/external-link-cache-egress-775.test.ts:

  • A private site's checks neither read nor write the cache. The public control still uses it.
  • A private site's loopback, localhost, single-label and .local links are checked locally and never sent to the bulk checker. With only such links, it is not called.
  • A blocked_non_public_host answer on a public site's audit is checked locally, refused, not broken and not cached. On a private site's audit it is checked locally and answered. Any other bulk error stays the answer.

packages/audit-engine/tests/external-links-not-requested-2759.test.ts has a new test: on a public site's audit, the action and token links, by URL or by link text, are never sent to the bulk checker. It uses a public name, and the service answers everything it is asked, so nothing goes to the network.

apps/cli/tests/crawler/link-cache-public-only-775.test.ts:

  • A row written by an older version (the old schema, then migrated) is not served.
  • A new write is served.

Changed tests

The pub#753 chunking tests and the repo#2759 "action URL handed directly" test sent loopback fixture links to a fake bulk checker. That is exactly what this change stops.

  • They now name the fixture by a public-looking name resolved to it through the policy's resolve. The CLI pub#753 test does this through the engine's checkExternalLinks, imported from a new @squirrelscan/audit-engine/external-checker subpath export.
  • The pub#753 end-to-end test, a crawl of a localhost site with loopback external links, is renamed to what it now shows: the service is never called, and the summary reports the local results. The unanswered-chunk path stays covered by the checkExternalLinks tests in the same file.

Also re-run: external-link-refused-770, external-link-egress-2759, link-checks-not-run-e2e, and the CLI cloud-spend, quick-skips-cloud and streamed-payload-parity tests.

Docs and skill

  • configuration/external-links: the cache section says only public site audits use the cache. The redirect and refusal paragraph covers the bulk checker gate and cloud refusals.
  • CHANGELOG has two entries under Security.
  • The squirrelscan agent skill needs no change.

nc9 added 2 commits October 15, 2026 17:11
…e; the bulk checker gets public links only #775

- The shared link cache is read and written only under a public-only egress
  policy, so a public site's audit is never answered with a verdict a
  private-network check produced. The CLI cache ignores rows from before
  this rule (new public_only column), which also drops cloud refusals
  cached as broken links.
- The cloud bulk checker is never sent a link whose URL names a non-public
  host, whatever the policy; those take the local check.
- A bulk answer of blocked_non_public_host is a refusal, not a verdict: the
  link takes the local check and is never recorded as broken.

The pub#753 and repo#2759 bulk tests now name their loopback fixture by a
public-looking name resolved there.

Signed-off-by: Nik Cubrilovic <[email protected]>
…licies skip the cache, tests keep their intent

- Docs/CHANGELOG: a public site's audit refuses non-public links rather
  than checking them, and a cloud refusal is never reported broken (no
  claim about how it is checked).
- isPublicOnlyEgress also excludes allowHost policies; the refusal match
  needs the 'blocked_non_public_host:' prefix with its colon.
- checkExternalLinks via a subpath export, not the engine index.
- New unit test: a public site's action/token links (URL or text) never
  reach the bulk checker; the 753 e2e is renamed to what it shows.

Signed-off-by: Nik Cubrilovic <[email protected]>
@nc9
nc9 force-pushed the fix/link-cache-egress-775 branch from aaae3c7 to ec60bb9 Compare October 15, 2026 06:11
… isPublicOnlyEgress per policy field

Signed-off-by: Nik Cubrilovic <[email protected]>
@nc9
nc9 marked this pull request as ready for review October 15, 2026 06:17
@claude

claude Bot commented Oct 15, 2026

Copy link
Copy Markdown

Reviewed the diff (cache gating, bulk-checker filtering, schema migration, tests). I found no blocking problems.

  • (low) packages/audit-engine/src/external-checker.ts: isBulkNonPublicRefusal matches the literal blocked_non_public_host: prefix from the cloud service. If the service changes that string, a refusal would again be stored as a broken link, and nothing here would catch it. A test pinning the constant against the service's contract would help, and the new 775 test may already cover part of this.
  • (low) apps/cli/src/crawler/storage/link-cache.ts: rows written by older versions have public_only NULL. They are never served, but they stay in the table until the TTL cleanup removes them. This is harmless. Say so in a comment if the cleanup also deletes by checked_at.
  • (nit) The isPublicOnlyEgress doc comment reads awkwardly ("and any host, so a verdict it produced holds for any audit. One that allows…"). The line is also over-long, so it needs a reflow.
  • (nit) isPublicOnlyEgress treats any new EgressPolicy field as public-only by default. Add a comment, or a type-level exhaustiveness check, so a future permissive field isn't missed.

The tests cover the migration of an old-schema DB, the new-write path, and the bulk filtering.

@nc9
nc9 merged commit f5c44ca into main Oct 15, 2026
16 checks passed
@nc9
nc9 deleted the fix/link-cache-egress-775 branch October 15, 2026 06:42
nc9 added a commit that referenced this pull request Oct 15, 2026
…ache #800

After the rebase onto pub#802 the link cache is used only under a
public-only egress policy, so the cache tests use the bulk checker and
cached answers, not the loopback server. One cacheableVerdict() decides both
cache writes (throttled, refused and unverifiable verdicts are never cached).

Signed-off-by: Nik Cubrilovic <[email protected]>
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.

External link check: the link cache is not keyed by egress policy, and a private site's links go to the cloud bulk check

1 participant