Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[3.10] gh-113171: gh-65056: Fix "private" (non-global) IP address ranges (GH-113179) (GH-113186) (GH-118177) #118229

Merged
merged 2 commits into from
May 7, 2024

Conversation

encukou
Copy link
Member

@encukou encukou commented Apr 24, 2024

Note that 3.10 has slightly different semantics of is_private on networks; see the second commit here.

GH-113171: Fix "private" (non-global) IP address ranges (GH-113179)

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] #61602

(cherry picked from commit 2a4cbf1)

GH-65056: Improve the IP address' is_global/is_private documentation (GH-113186)

It wasn't clear what the semantics of is_global/is_private are and,
when one gets to the bottom of it, it's not quite so simple (hence
the exceptions listed).

(cherry picked from commit 40d75c2)


(cherry picked from commit f86b17a)


📚 Documentation preview 📚: https://cpython-previews--118227.org.readthedocs.build/

encukou and others added 2 commits April 24, 2024 14:55
…s ranges (pythonGH-113179) (pythonGH-113186) (pythonGH-118177)

* pythonGH-113171: Fix "private" (non-global) IP address ranges (pythonGH-113179)

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] python#61602

* pythonGH-65056: Improve the IP address' is_global/is_private documentation (pythonGH-113186)

It wasn't clear what the semantics of is_global/is_private are and, when
one gets to the bottom of it, it's not quite so simple (hence the
exceptions listed).

(cherry picked from commit 2a4cbf1)
(cherry picked from commit 40d75c2)

---------

(cherry picked from commit f86b17a)

Co-authored-by: Jakub Stasiak <jakub@stasiak.at>
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").
@encukou
Copy link
Member Author

encukou commented Apr 29, 2024

DBM tests (test_dbm, test_shelve, test_dbm_ndbm) fail on MacOS 14 GitHub Actions.
@ned-deily, do these failures ring a bell?

@encukou encukou added type-security A security issue release-blocker 3.10 only security fixes labels May 2, 2024
@ned-deily
Copy link
Member

Do these failures ring a bell?

Sorry, they don't at all. I tried to reproduce them in a non-GHA environment with and without the PR but without any failures.

@encukou
Copy link
Member Author

encukou commented May 3, 2024

Thanks!
Looks like this failure happens on all 3.10 backports, so this PR should be fine.

@ambv ambv merged commit c62c9e5 into python:3.10 May 7, 2024
14 of 15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.10 only security fixes release-blocker skip news type-security A security issue
Projects
Development

Successfully merging this pull request may close these issues.

3 participants