fix(check): judge the certificate where the visitor lands, and actually fetch the declared og:image

Two false-verdict classes, both found by an outside review of the v1 wording:

- TLS read the certificate of the host the visitor typed. When apex redirects to www,
  or a CDN name fronts the site, the report judged the redirector. It now walks the
  chain with HEAD requests (no page bodies) and judges the final address, keeps the
  typed certificate as evidence, and takes the worse of the two. A blocked or
  unreachable target stays 'not checked' with a reason, never 'broken'.
- The WhatsApp preview read og:image and printed its URL without fetching it. A 404,
  an HTML page, a 2 MB PNG or a WebP all looked like a working card. It now sends one
  guarded HEAD (1 KB GET fallback) and reports status, type and size.

Also: requestOnce takes an explicit Accept header so an image fetch is not answered
with text/html, and the about page no longer claims 'exactly one connection' now that
two bounded HEAD requests exist.
This commit is contained in:
hoelee committed 2026-11-10 16:25:00 +08:00
1 parent 4049d663a7
commit e4f50e9cf4
8 files changed
+1391 -50

No files matched your search

+6 -2
View File
@@ -37,8 +37,12 @@ import `node:http`/`node:https` directly, must not use the global `fetch`, and m
trust anchor, so a SHA-1 root is not a failure.
- HTTP headers: a missing CSP or Permissions-Policy is **"optional hardening not present"**, not
"insecure". Only a broken redirect chain or malformed HSTS is a failure.
6. **One connection per check.** The certificate comes off the same socket as the HTTPS request
(`requestOnce` already returns `.tls`). Do not open a second connection to the same host.
6. **No redundant connections.** The certificate comes off the same socket as the HTTPS request
(`requestOnce` already returns `.tls`); when a site redirects, the certificate at the final
address is read from that redirect's own socket rather than a fresh handshake. The only extra
traffic allowed is bounded and named: up to five HEAD hops with no page body to find where a
redirect lands, and one HEAD for the declared `og:image`. If you add a sub-request, say why and
cap it.
7. **Cache before you scan.** A shared report URL is prefetched by WhatsApp/Telegram, so a cached
report is served without touching the target. Negative and warning results cache for 5 minutes;
clean results for 1 hour.