Skip to content

fix(cli): list dead-links results the cloud checker could not verify as unverifiable, never broken (squirrelscan/repo#2818) - #762

Merged
nc9 merged 2 commits into
mainfrom
fix/dead-links-unverified-2818
Oct 14, 2026
Merged

nc9 merged 2 commits into
mainfrom
fix/dead-links-unverified-2818

Conversation

@nc9

@nc9 nc9 commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Public half of squirrelscan/repo#2818. It pairs with squirrelscan/repo#2829, the private PR that makes the cloud dead-links service send these fields.

When you are signed in, the cloud dead-links service checks your external links through Perch. A Perch verdict the checker could not settle either way had no way to reach the rules as "not verified":

  • bot protection refused the request;
  • the link timed out or failed to connect from our network;
  • it is a first 404 waiting for its confirming second check.

So a timeout came back as a broken link (Error: timeout), and a refused link disappeared from the report.

  • DeadLinkResult (packages/core-contracts/src/services.ts) gains optional wafBlocked and wafProvider. These are the names ExternalCheckResult already has, and the WAF-blocked "status unverifiable" bucket in links/broken-external-links already reads them.
  • The CLI's dead-links bulk checker (apps/cli/src/audit/cloud.ts) passes them to the engine. A vendor outside the engine's WafProvider vocabulary becomes unknown, so no new dependency is added.
  • An older service omits both fields, and nothing changes.
  • Docs: rules/links/broken-external-links says the WAF list also holds what the cloud checker could not verify. rules/links/dead-links names those cases and points to the list.
  • The CLI's vendor list is checked against the engine's WafProvider type at compile time (satisfies).
  • CHANGELOG: an [Unreleased] Fixed entry.

Merge order (#2818's last criterion): this PR first. The private PR sends the fields, and it does not need a gitlink bump: until the next routine bump it declares them in a twin type named after this contract. On the wire, either order is safe: an unverified result has no status and no error (a refused 403 included), so a client that predates these fields reads the link as unchecked, never broken. The CLI half takes effect with the next CLI release.

Follow-up filed: #764 (the local link cache keeps cloud rate-limited and unverified answers for 7 days).

Verification

  • apps/cli: bun test tests/audit/cloud-spend.test.ts passes 9, 2 of them new: a wafBlocked result keeps its flag and a known vendor, an unknown vendor reads unknown, and a result without the flag carries none.
  • apps/cli: typecheck, lint and format:check are clean. packages/core-contracts: typecheck is clean.
  • docs: bun x [email protected] check --strict reports all checks passed.

Checklist

  • I added or updated tests for behavioral changes.
  • I did not include secrets, customer data, or incompatible third-party material.
  • Every commit includes a DCO Signed-off-by line (git commit -s).

Agent skill (squirrelscan/skills): no change needed.

@claude

claude Bot commented Oct 14, 2026

Copy link
Copy Markdown

Reviewed the diff and the engine code it plugs into. The change is small and consistent, and I found nothing blocking.

  • (low) apps/cli/src/audit/cloud.ts:~718: filterBrokenLinks (packages/audit-engine/src/external-checker.ts:~353) tests r.error first, so a result with wafBlocked: true and a non-null error is still counted as broken. The contract comment says error is null for these results, but the CLI doesn't enforce that. If the service ever sends both, the old Error: timeout behaviour comes back. Either null error when wafBlocked is true here, or add a test that pins the service invariant.
  • (nit) WAF_PROVIDERS builds its set by listing keys in an object literal. The satisfies Record<WafProvider, true> check catches a vendor added to the engine, but it won't catch one removed from it, because the extra key would fail the check only if excess-property checking applies. That should apply to an object literal, so this is probably fine. Worth a quick confirmation that a bogus key fails to compile.
  • (nit) Test coverage: there is no case for a wafBlocked result with wafProvider missing, which should read unknown. knownWafProvider handles it, but a test would pin the behaviour. There is also no end-to-end check that these results land in waf-blocked-external-links rather than broken-external-links.
  • (nit) The rateLimited and wafBlocked flags can both be set on one result, and the docs say rate-limited links go under rate-limited-external-links. The docs don't say whether such a link appears in both lists.

Security: provider strings from the service are allow-listed to the engine's vocabulary, so a value like <script> can't reach the report. Compatibility: the new fields are optional, so older services behave as before. The docs and CHANGELOG entries are clear.

nc9 added 2 commits October 14, 2026 22:24
…as unverifiable, never broken (squirrelscan/repo#2818)

DeadLinkResult gains optional wafBlocked and wafProvider. The service sets them for a link it could not verify either way: bot protection, a timeout or failed connection from its network, or a first 404 waiting for its confirming check. The CLI passes them to the engine, so the rules list the link with the firewall-blocked ones as status unverifiable. A vendor outside the engine's vocabulary reads as unknown. Older services omit the fields and nothing changes.

Signed-off-by: Nik Cubrilovic <[email protected]>
…or list to the engine type (squirrelscan/repo#2818)

Review round 1. An unverified result's status and redirectUrl are null, a refused 403 included, so a CLI that predates the flag reads the link as unchecked rather than broken. The CLI's vendor list is checked against WafProvider at compile time. dead-links docs name what the service could not verify and where it is listed.

Signed-off-by: Nik Cubrilovic <[email protected]>
@nc9
nc9 force-pushed the fix/dead-links-unverified-2818 branch from fa12987 to 42fc7c4 Compare October 14, 2026 11:25
@nc9

nc9 commented Oct 14, 2026

Copy link
Copy Markdown
Contributor Author

Rebased onto main 7e991f5 (#755, #757), new head 42fc7c4, DCO on both commits. The one conflict was the same paragraph in docs/rules/links/dead-links.mdx, and both edits are kept: #755's 200-link chunk / stop-asking sentence and this PR's list of what the service could not verify. Both CHANGELOG [Unreleased] entries are kept (#753 and squirrelscan/repo#2818). #755 moved the bulk-result path into the engine (checkExternalLinks), and it already carries wafBlocked / wafProvider into results and the cache, so this PR's CLI mapping still reaches the rules. Re-run: cloud-spend + dead-links-unanswered-753 tests 12 pass; typecheck, lint and format:check clean in apps/cli; core-contracts typecheck clean; tangly check --strict passes. Merge this before squirrelscan/repo#2829.

@claude

claude Bot commented Oct 14, 2026

Copy link
Copy Markdown

Review of #762: no blocking issues. The fields line up with the engine: ExternalCheckResult is exported, the WafProvider list matches waf-detect, and filterWafBlockedLinks keys on wafBlocked === true. I did not run the tests.

  • (low) apps/cli/src/audit/cloud.ts: filterBrokenLinks returns true when r.error is set, before it checks wafBlocked. The CLI passes error through unchanged. The PR relies on the service sending error: null for unverified results, as the PR description says. If a service ever sent wafBlocked: true together with an error string, the link would count as broken and also appear in the WAF list. Consider either clearing error when wafBlocked is true in the mapper, or adding a test for that combination.
  • (nit) apps/cli/src/audit/cloud.ts: WAF_PROVIDERS is built through Object.keys on an object literal with satisfies Record<WafProvider, true>. This works and gives the compile-time check the PR describes. A short comment saying the literal is only there for the type check would help the next reader.
  • (nit) packages/core-contracts/src/services.ts: wafBlocked also covers timeouts and first 404s, so the name no longer says what it means. It is fine to keep it because it matches the engine's field, but the doc comment already covers this.
  • (nit) CHANGELOG.md: the entry is accurate. It is long, but that matches the neighbouring entries.

Test coverage is good: it covers a known vendor, an unknown vendor, and a result without the flag.

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.

1 participant