Repository navigation
fix(audit-engine): list refused external links; refuse before the link cache and bulk checker #770 - #773
Conversation
…k cache and bulk checker #770 Follow-ups to #767's egress guard on the external link check: 1. A link whose address the policy refuses (a private, link-local or metadata address on a public site's page) was stored unresolved and left out of every report line. checkCollectedExternalLinks now records them in stats.externalLinkCheck (refused, refusedLinks: masked sample with pages, the same builder as the not-requested sample), and links/broken-external-links lists them in a refused-external-links info check, never as working or broken. 2. checkExternalLinks consulted the link cache and the bulk checker before the guard, so a verdict a private site's audit cached for the same URL could be served into a public site's report, and the URL sent to the cloud. A new refusedWithoutLookup (@squirrelscan/utils/public-egress) settles what the URL alone decides (scheme, allowHost, refused IP literal, metadata name, non-public name the policy does not allow) before either is asked. 4. Docs list the headers the check sends, Accept-Encoding included. Signed-off-by: Nik Cubrilovic <[email protected]>
…; the rule never reads them as not checked #770 From review: - All links refused made the rule say "None of the N external link(s) could be checked", a not-checked skip that holds the rule's cloud issues open. Refused links are no longer stored as rows (they were never requested), and when every external link was left out or refused only those info lines are emitted. - Links refused on the URL alone are now left out before selection, like the not-requested ones: they take no slot under max_links and are not counted as checked (stats.externalLinkCheck.refusedByUrl; the over-limit denominator leaves them out). Rule-data builders drop stale rows the policy would refuse, through a shared externalLinkEgress(baseUrl). - The second stats write logs on failure; docs comment and CHANGELOG wording (link-local and metadata refused on every audit). Signed-off-by: Nik Cubrilovic <[email protected]>
… not write #770 From review: skipping the row write for a refused link let a row copied from an earlier crawl (incremental reuse copies a reused page's link rows, not their appearances) survive with its old verdict, for a name refused after lookup. Both builders now drop external rows with no appearance in this crawl: only this run's external phase writes appearances, so a copied row is a verdict this audit never made. That also retires stale verdicts for links over the limit. Refused links keep their appearances. The re-audit test adds a metadata-address row and a row for a link the run never checks; without the filter it fails on v1 and v2. Docs and CHANGELOG say which refusals take no slot. Signed-off-by: Nik Cubrilovic <[email protected]>
…ot rows without appearances #770 From review: keeping appearances for a link refused after its DNS lookup made the zero-appearances test pass for a row copied from an earlier crawl, so that row's old verdict was reported again (and copied forward on every re-audit). The builders now drop external rows whose checkedAt is older than this crawl's start: incremental reuse copies rows with their old checkedAt, and this run's external phase stamps every row it writes. The re-audit test simulates the refused-after-lookup shape (a row older than the run beside an appearance it wrote) and seeds its stale rows a minute old (same-millisecond seeds made it flaky). Appearance batch failures now log a warning. Signed-off-by: Nik Cubrilovic <[email protected]>
Signed-off-by: Nik Cubrilovic <[email protected]>
…758 From #771's review: with a few coarse lastmods beside a news sitemap (fewer than 20 in all), neither the news-only nor the too-coarse skip applies, and the generic one said "Only 0 sitemap URL(s) carry a lastmod". It now counts the coarse values, which do carry a lastmod. Test added. Signed-off-by: Nik Cubrilovic <[email protected]>
b7e199b to
408d527
Compare
|
Review of #773. I read the diff and
Tests cover the cache and bulk-checker bypass, the stats and sample masking, and the stale-row case in v1 and v2. The code reads cleanly and the security direction is right. A refused link can no longer be answered from the cache or a remote service, and nothing is stored for it. I found no blocking issues. |
…rtedAt #770 Review follow-up. refusedWithoutLookup also refuses other schemes and unparseable URLs; pin that collection never yields them, so a URL-refused link is always an address refusal. Pin that a resume keeps the crawl's startedAt, which the checkedAt filter depends on. Rewrap a doc line. Signed-off-by: Nik Cubrilovic <[email protected]>
|
Triage of the review on 408d527. The follow-up is f4179b3: tests plus one doc rewrap, no behaviour change. (medium) (medium) the
(low) (low) (nit) the Accept-Encoding doc line. It belongs here: since #767 every hop goes through (nit) long CHANGELOG entry. Leaving it as is. |
|
Review of #773. I read the diff only and did not run the tests or check CI. No critical or high findings. The refusal now happens before the cache and the bulk checker, refused links never get a row, and the stale-row filter is covered by tests, including the resume case that keeps
|
Closes #770 (items 1, 2 and 4; item 3 landed in #767). Also carries a small #758 follow-up (below).
What changed
These follow up #767, which put the external link check behind the egress guard.
checkCollectedExternalLinksnow records these links instats.externalLinkCheckasrefused(a count) andrefusedLinks. The sample uses the same builder as the not-requested links: the 50 most-linked, each with 10 source pages and itspageCount, URLs masked, and masked duplicates merged.links/broken-external-linkslists them in a new info check,refused-external-links. They are never reported as working or broken. Message template:N external link(s) point at a private, link-local or cloud metadata address, so they were not requested and their status was not checked.max_linksand are not counted as checked (refusedByUrl), and the over-limit denominator leaves them out. Refused links are never stored as rows, but their appearances are written.checkedAtis older than the crawl's start. Incremental reuse copies a reused page's link rows from earlier crawls with their oldcheckedAt, and this run's external phase stamps every row it writes. So a link refused (before or after its DNS lookup), left out, or not reached under the limit can no longer report an old verdict.checkExternalLinksused to read the link cache and call the bulk checker before the guard. The CLI's link cache is global, so a verdict that a private site's audit cached forhttp://192.168.1.1/...could be served into a public site's report, and the URL sent to the cloud.refusedWithoutLookupin@squirrelscan/utils/public-egresssettles what the URL alone decides before either is asked: the scheme,allowHost, a refused IP literal, a metadata hostname, and a non-public name the policy does not allow.falseis not an approval.Accept-Encoding.Also folded in, from #771's review (#758):
crawl/sitemap-lastmod-churn's "too small to judge" message now counts year and month lastmods. A sitemap with only a few of them used to readOnly 0 sitemap URL(s) carry a lastmod. A test is added.Remaining, out of scope here: the link cache is not keyed by policy, and a private site's non-public links still go to the cloud bulk check (#775).
Acceptance criteria
links/broken-external-linksas not requested, with a reason and a masked sample, and is never counted as working or as checked. It is never stored as a row. A link refused on its URL alone is left out before selection, so it takes no slot undermax_links(refusedByUrl). When every external link was left out or refused, only those info lines appear: no "could not be checked" skip.Verification
packages/utils:public-egress.test.tspasses 123 tests, 3 of them new forrefusedWithoutLookup: refusals on a public site, public names left to the request, and a private site's allowances.packages/audit-engine: the newexternal-link-refused-770.test.tspasses 2 tests, covering the cache and bulk checker not being asked, and the stats sample (masked, counted, no rows stored). Both fail against main. The 2759 re-audit test now also seeds old verdicts for a metadata-address link and for a link the run never checks, and simulates the refused-after-lookup shape (a row older than the run beside an appearance the run wrote). On v1 and v2 it fails without the copied-row filter. The neighbour tests pass:external-link-egress-2759,external-links-not-requested-2759,bulk-checker-unanswered-753,fetch-deadline,undecoded-probe-fetches,link-checks-not-run-e2eandstreaming-pre-rules-golden.packages/rules:external-links-not-requested-2759.test.tsandlink-checks-not-run.test.tspass 29 tests. New cases: a refused link listed but not counted, a limit not reached because of it, and every link left out or refused with no not-checked skip.apps/cli:dead-links-unanswered-753andcloud-spendpass 12 tests.tsgo --noEmitis clean in utils, core-contracts, rules and audit-engine. oxlint shows nothing new, the new test file is oxfmt-clean, and detect-secrets is clean.docs/:tangly check --strictpasses.Agent skill
No change needed.