test(auth): pin loopback host spellings and drop the unreachable ::1 arm #12
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "test-loopback-host-spellings"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes #3 for this repository.
What changed
The two rows of the shared redirect-URI case table that nothing here asserted:
loopback_spellings_normalise_to_one_host—127.1,0177.0.0.1and2130706433land on the same outcome as127.0.0.1, in both directions(as a requested
redirect_uri, and as an entry an operator wrote), and127.0.0.2still does not.bracketed_ipv6_loopback_is_a_loopback_host—[::1]port-relaxes,[::2]does not, the relaxation does not cross address families, and the unbracketed
form does not parse as a URL at all.
Both behave correctly today, so this records behaviour rather than fixing a
bug. It is worth recording because the behaviour is the
urlcrate's hostnormalisation and not anything this repo wrote: a crate bump could change which
spellings the allowlist admits with nothing else going red.
is_loopback_hostalso loses its unbracketed"::1"arm. Both call sites passUrl::host_str(), which returns the bracketed form for every IPv6 host, so thearm was unreachable. In a security predicate an unreachable arm reads as
coverage that is not there.
With these two, all nine rows of the table in
the decision comment on #3
are pinned in this repo, with no dependency on any other repo.
Verified by mutation
Each mutation was run against the full suite, and each killed exactly one test.
1. Compare the authority as written instead of the normalised host
(
raw_host(entry) != raw_host(uri) → return false, inserted ahead of theUrl::parse):Every other test stayed green, which is the point: nothing else in the suite
was pinning the normalisation.
2. Drop the
"[::1]"arm fromis_loopback_host:That the removal of the unbracketed
"::1"arm changes nothing is thecomplementary evidence: the full suite is green without it, and
parse_allowlist("http://::1:8787/callback").is_err()asserts the form cannotarrive.
Not in this change
The cross-repo comparison of the case table floated in #3 — a check living in
mantis, which depends on all five and is depended on by none. It is markedoptional there and it is not this repo's to carry.
Gates
cargo fmt --check,cargo clippy -D warnings,cargo test --all-features(103 passed),
cargo audit,cargo deny check bans licenses sources— allgreen locally on
rustc 1.98.0.