Repository navigation
fix(rules): Cloudflare email-protection links are not broken links #811 - #829
Conversation
|
Review of #829 (Cloudflare email-protection links are not broken links) I read the diff only. I did not run the tests or check CI. The change is well scoped. It filters at the parser, the crawler queue, the site-asset collector and the rule. The rule also filters by URL, so parses stored before this change are handled. Tests cover the helper, the parser, the rule, and an end-to-end run on both engines and both crawl modes.
I found no correctness or security problems. |
|
Review triage (fixed in afb7bc2):
|
|
Review of #829 (skip Cloudflare email-protection links in broken-links). I read the diff and the new I found no high or critical problems. The approach holds up: the parser drops these links, the stored-parse path is still covered in
The CHANGELOG entry and docs look good. |
|
Second review round (fixed in 46702f3):
|
With Cloudflare's email obfuscation on, every mailto: link and address in the text becomes /cdn-cgi/l/email-protection, which answers an error when requested, so links/broken-links listed one broken link per address sourced from every page. The parser now leaves these out of the link graph (so the crawl, the internal link check and the external link check never request them) and carries each as the mailto: contact link it stands for, decoded and flagged obfuscated. links/broken-links and the internal link check also skip them in parses stored before this, and the broken-links row reports details.emailProtectionLinks. Other /cdn-cgi/ links (image resizing) are still checked. Signed-off-by: Nik Cubrilovic <[email protected]>
…e decoder #811 The e2e fixture's hex payloads tripped the secret scan; they are now encoded by a helper. isCloudflareEmailProtectionUrl skips the URL parse for links without /cdn-cgi/, decodeCloudflareEmail refuses payloads longer than any address, and the docs say how emailProtectionLinks counts (per link per page, at most 32 contact links a page). Signed-off-by: Nik Cubrilovic <[email protected]>
A footer of Cloudflare email-protection links could fill the 32-item contact list and push out the tel: links local/nap-consistency reads. Obfuscated links now count against a cap of their own. Signed-off-by: Nik Cubrilovic <[email protected]>
46702f3 to
111ed09
Compare
|
Reviewed the full diff. I didn't run the tests, only read the code. The change is small and well scoped.
Test coverage is good: unit, parser, rule and end-to-end tests for both the v1 and v2 engines and for stored old parses. I have no blocking concerns. |
Closes #811.
What changes
With Cloudflare's Email Address Obfuscation on, every
mailto:link becomes/cdn-cgi/l/email-protection#<hex>, and every address in the text becomes<a href="/cdn-cgi/l/email-protection" data-cfemail="<hex>">. A script puts the address back in the browser. Requested directly, the path answers an error, solinks/broken-linkslisted one "broken internal link" per address, with every page carrying it in its footer as a source.html.tsextractLinks, which feeds storedparsedDataand the rules, andextractors/links.ts, which feeds the crawl queue and the external link collection) leave these links out on any host. So the crawl never queues one, the internal link check never sees one, and the external link check never requests one on another site.extractContactLinksrecords each one as themailto:it stands for, withobfuscated: "cloudflare"(new optional field onContactLinkData). The address is decoded the way Cloudflare's script does it (key byte XOR, UTF-8), orvalue: ""when the payload does not decode to an address.local/nap-consistency(viaextractNapSignal) now sees these pages as having a mailto link.parsedData) still has the links inlinks.links/broken-linksand the internal link check's target collection (audit-engineadapter) skip them by URL too.broken-linksrow carriesdetails.emailProtectionLinks(anchors left out, from both sources) when there were any./cdn-cgi/l/email-protectionis skipped, not every/cdn-cgi/path as the issue's Expected section suggested. Cloudflare image-resizing URLs (/cdn-cgi/image/...) are real resources that sites do link to, and a broken one should still be reported. A test pins this.@squirrelscan/utils(cloudflare-email.ts, also exported at@squirrelscan/utils/cloudflare-email):isCloudflareEmailProtectionUrl,decodeCloudflareEmail.Tests
packages/utils/tests/cloudflare-email.test.ts: path matching (relative, absolute, any host, case, not other/cdn-cgi/paths), decoding, and malformed payloads.packages/parser/tests/contact-links.test.ts: an obfuscated mailto link and adata-cfemailaddress (on the anchor and nested) become contact links and leavelinksempty. Also covers an undecodable payload, another host (extractLinksin both extractors), the crawl queue (extractCrawlableUrls), and an image-resizing link staying a link.packages/rules/tests/cf-email-protection-811.test.ts: a stored-parse link the crawl or the internal check got a 404 for is not broken and is counted. Obfuscated contact links are counted on a pass and beside a real broken link. Plain mailto links are not counted. A broken/cdn-cgi/image/...link is still broken.packages/audit-engine/tests/cf-email-protection-811-e2e.test.ts: real crawler, a local server whose/cdn-cgi/answers 404, both rule engines, crawl following links and not. Nothing under/cdn-cgi/is requested,broken-linkspasses, andemailProtectionLinks: 4. A stored pre-fix parse is never probed either. I confirmed that case fails with the adapter skip removed.link-checks-not-run,rate-limited-links(rules), andlink-targets-not-fetched-726-e2e,link-coverage-794-e2e,link-targets-fetched-798-e2e,site-query-nap-rule-golden(audit-engine). tsgo is clean for utils, parser, rules, audit-engine, core-contracts and apps/cli.test-suites.ts --checkpasses, and so doestangly check --strict./gone404, at--level quickand--level full: the server log has no/cdn-cgi/request,/goneis the only broken link, anddetails.emailProtectionLinksis 4.Docs and skill
rules/links/broken-links: a bullet on why these links are skipped and what they are read as, plusemailProtectionLinksin the details list.configuration/external-links: the internal and external "never requests" sections name these links.