Commit f14e7aa
committed
Tighten bracketed-host parsing to RFC 3986 / RFC 6874 strict semantics
RFC 3986 §3.2.2 reserves bracket syntax for IPv6 literals
(``IP-literal = IPv6address / IPvFuture``). The parser previously
extracted the bracket contents and forwarded them to
``_canonicalize_host`` without enforcement, so ``[127.0.0.1]:9001``,
``[localhost]:9001``, and ``[example.com]:9001`` all silently
succeeded. The raw ``address`` string is stored verbatim on
``DqliteConnection._address`` and surfaces in repr / logs /
exception messages, so log audits and string-based diagnostics
fragmented across two surface forms for the same logical host.
Validate the bracket contents with ``ipaddress.ip_address`` and
require an ``IPv6Address`` (not ``IPv4Address``); reject empty and
whitespace-only contents.
RFC 6874 specifies that IPv6 zone identifiers may be percent-encoded
in URIs (``%25`` escapes the literal ``%`` zone separator). The
application-form ``[fe80::1%eth0]`` and the URI-form
``[fe80::1%25eth0]`` refer to the same logical zone but were treated
as distinct host strings. ``urllib.parse.unquote`` decodes the zone
suffix so both surface variants canonicalise to the same tuple —
allowlist policies holding one form match either.1 parent 52c4fa5 commit f14e7aa
2 files changed
Lines changed: 97 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
628 | 628 | | |
629 | 629 | | |
630 | 630 | | |
631 | | - | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
632 | 637 | | |
633 | 638 | | |
634 | 639 | | |
635 | 640 | | |
636 | 641 | | |
637 | 642 | | |
638 | | - | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
| 680 | + | |
639 | 681 | | |
640 | 682 | | |
641 | 683 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
0 commit comments