mirror of
https://github.com/yogeshojha/rengine.git
synced 2026-10-20 23:31:31 +02:00
A row states that a favicon, page title, body hash, certificate, CNAME target or address is also held by a host under a different target, and the popover names the peers and pivots to the query that returns them. Read against the estate, so a row on a single-scan page still reaches the other targets. The refusal is the feature. Measured across four unrelated estates, all five cross-target values were a provider's and none is drawn. A carrier on a SHARED_EDGE_HOSTS CNAME vouches for no identity. generic_page() refuses a title that restates the status of the rows carrying it, the soft-404 phrases and the curated edge interstitials, and it gates the three page-derived kinds. cert_covers() requires a certificate to name the host presenting it, so *.okta.com on a tenant is not a link. JARM spanned all four estates and is not a cross link. Each value is judged once before the row loop and _crossing() refuses to fetch carriers for a value one target holds: a wildcard CNAME with 8,679 carriers cost 4.6s a page, now ~80ms. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LxAonr95Uj7Bdu4CTMCwx9
60 lines
1.8 KiB
Python
60 lines
1.8 KiB
Python
import ipaddress
|
|
import socket
|
|
from collections.abc import Iterable
|
|
from urllib.parse import urlsplit
|
|
|
|
|
|
def is_registry_routable(value: str) -> bool:
|
|
"""Whether an address or netblock sits in public space an RIR can hold a record for."""
|
|
try:
|
|
net = ipaddress.ip_network(value.strip(), strict=False)
|
|
except ValueError:
|
|
return False
|
|
return net.is_global and not net.is_multicast
|
|
|
|
|
|
def validate_public_https_url(raw: str, *, label: str = "URL") -> None:
|
|
parts = urlsplit(raw)
|
|
if parts.scheme != "https" or not parts.hostname:
|
|
msg = f"{label} must be an https:// URL."
|
|
raise ValueError(msg)
|
|
try:
|
|
infos = socket.getaddrinfo(parts.hostname, None)
|
|
except OSError as exc:
|
|
msg = f"Cannot resolve {label} host: {exc}"
|
|
raise ValueError(msg) from exc
|
|
for info in infos:
|
|
ip = ipaddress.ip_address(info[4][0])
|
|
if (
|
|
ip.is_private
|
|
or ip.is_loopback
|
|
or ip.is_link_local
|
|
or ip.is_reserved
|
|
or ip.is_multicast
|
|
or ip.is_unspecified
|
|
):
|
|
msg = f"{label} resolves to a disallowed address."
|
|
raise ValueError(msg)
|
|
|
|
|
|
def cert_covers(
|
|
host: str | None, subject_cn: str | None, sans: Iterable[str] = ()
|
|
) -> bool:
|
|
"""Whether a certificate names the host presenting it."""
|
|
if not host:
|
|
return False
|
|
target = host.strip().lower().rstrip(".")
|
|
for raw in (subject_cn, *sans):
|
|
if not raw:
|
|
continue
|
|
name = str(raw).strip().lower().rstrip(".")
|
|
if name == target:
|
|
return True
|
|
if (
|
|
name.startswith("*.")
|
|
and target.endswith(name[1:])
|
|
and target.count(".") == name.count(".")
|
|
):
|
|
return True
|
|
return False
|