]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
[3.8] gh-113171: gh-65056: Fix "private" (non-global) IP address ranges (GH-113179...
authorPetr Viktorin <encukou@gmail.com>
Tue, 7 May 2024 09:58:20 +0000 (11:58 +0200)
committerGitHub <noreply@github.com>
Tue, 7 May 2024 09:58:20 +0000 (11:58 +0200)
commit895f7e2ac23eff4743143beef0f0c5ac71ea27d3
treedb360c55b146771272f952cd75fcf693b0a8edc2
parentf791cda79331f64e46b5e561f2f85f116aa5c494
[3.8] gh-113171: gh-65056: Fix "private" (non-global) IP address ranges (GH-113179) (GH-113186) (GH-118177) (GH-118479)

The _private_networks variables, used by various is_private
implementations, were missing some ranges and at the same time had
overly strict ranges (where there are more specific ranges considered
globally reachable by the IANA registries).

This patch updates the ranges with what was missing or otherwise
incorrect.

100.64.0.0/10 is left alone, for now, as it's been made special in [1].

The _address_exclude_many() call returns 8 networks for IPv4, 121
networks for IPv6.

[1] https://github.com/python/cpython/issues/61602

In 3.10 and below, is_private checks whether the network and broadcast
address are both private.
In later versions (where the test wss backported from), it checks
whether they both are in the same private network.

For 0.0.0.0/0, both 0.0.0.0 and 255.225.255.255 are private,
but one is in 0.0.0.0/8 ("This network") and the other in
255.255.255.255/32 ("Limited broadcast").

---------

Co-authored-by: Jakub Stasiak <jakub@stasiak.at>
Doc/library/ipaddress.rst
Doc/tools/susp-ignored.csv
Doc/whatsnew/3.8.rst
Lib/ipaddress.py
Lib/test/test_ipaddress.py
Misc/NEWS.d/next/Library/2024-03-14-01-38-44.gh-issue-113171.VFnObz.rst [new file with mode: 0644]