You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
ipaddress "is_private" and "is_global" are insufficiently documented and is_global probably has a bug #65056
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
assignee=Noneclosed_at=Nonecreated_at=<Date2014-03-06.16:20:35.832>labels= ['type-bug']
title='ipaddress "is_private" and "is_global" are insufficiently documented and is_global probably has a bug'updated_at=<Date2014-03-06.21:50:40.486>user='https://github.com/bitdancer'
The 'is_private' and 'is_global' properties refer to the iana registries, but the terms 'private network' and 'public network' do no appear in the registry documentation. There is no way to know what these methods are going to return other than examining the source code.
In particular, without looking at the source code a best-guess interpretation of the documentation would lead one to expect that is_private would return true only for RFC1918 addresses, since that is the one place the term 'private' appears. Similarly, the naive interpretation of is_global would be that it would return False for all addresses listed in the ipv4 registry *except* 192.88.99.0/24, which is the only one whose global routing flag is True in the table.
I would submit that the fact that the latter is not true is a bug.
It is really not at all clear what 'is_private' means (see also bpo-17400, which introduced is_global), so I am completely unclear how to rewrite the documentation to fully specify it, other than to list out the address ranges that it considers private.
Oh, and just to make things more complicated, there are footnotes that some protocols allow global routing for protocol-allocated addresses that are otherwise not globally routable. It would be reasonable to for is_global to ignore this, but it should be documented that it does so.
loewis commented on Mar 6, 2014
loewismannequin
Mannequin
More actions
I'm always in favour of using official terminology (and adjust if that changes over time). So in this case, I agree with David's analysis, and suggest the following specification:
is_global returns False for all addresses where "Global" is "False" in the IPv4 or IPv6 Special-Purpose Address Registry
a new method is_private_use is introduced, giving True only for the RFC1918 addresses
a new method is_unique_local is introduced, giving True only for the RFC 4193 addresses.
is_private is deprecated. Alternatively, it could be preserved and documented to being the union of is_privte_use and is_unique_local.
I don't think it it necessary to discuss footnote 1 in the IPv6 registry ("not global unless a specific allocations says otherwise"). The specific allocations that might override this come right below, so if we implement the table, we would cover all those more specific case.
I'm puzzled why Teredo is listed as "not global"; my understanding is that the Teredo prefixes even get announced in BGP, and are fully global.
Activity
bitdancer commentedon Mar 6, 2014
The 'is_private' and 'is_global' properties refer to the iana registries, but the terms 'private network' and 'public network' do no appear in the registry documentation. There is no way to know what these methods are going to return other than examining the source code.
In particular, without looking at the source code a best-guess interpretation of the documentation would lead one to expect that is_private would return true only for RFC1918 addresses, since that is the one place the term 'private' appears. Similarly, the naive interpretation of is_global would be that it would return False for all addresses listed in the ipv4 registry *except* 192.88.99.0/24, which is the only one whose global routing flag is True in the table.
I would submit that the fact that the latter is not true is a bug.
It is really not at all clear what 'is_private' means (see also bpo-17400, which introduced is_global), so I am completely unclear how to rewrite the documentation to fully specify it, other than to list out the address ranges that it considers private.
bitdancer commentedon Mar 6, 2014
Oh, and just to make things more complicated, there are footnotes that some protocols allow global routing for protocol-allocated addresses that are otherwise not globally routable. It would be reasonable to for is_global to ignore this, but it should be documented that it does so.
loewis commentedon Mar 6, 2014
I'm always in favour of using official terminology (and adjust if that changes over time). So in this case, I agree with David's analysis, and suggest the following specification:
I don't think it it necessary to discuss footnote 1 in the IPv6 registry ("not global unless a specific allocations says otherwise"). The specific allocations that might override this come right below, so if we implement the table, we would cover all those more specific case.
I'm puzzled why Teredo is listed as "not global"; my understanding is that the Teredo prefixes even get announced in BGP, and are fully global.
jstasiak commentedon Dec 15, 2023
I second @loewis' conclusions, the current semantics is pretty confusing. In the meantime we can document it better, I'll take a stab at it.
pythonGH-65056: Improve the IP address' is_global/is_private document…
jstasiak commentedon Dec 15, 2023
See the attached PR. The documentation preview: https://cpython-previews--113186.org.readthedocs.build/en/113186/library/ipaddress.html#ipaddress.IPv4Address.is_private
GH-65056: Improve the IP address' is_global/is_private documentation (G…
encukou commentedon Mar 18, 2024
Docs are now updated; thank you!
The bug is tracked in #113171.
pythonGH-65056: Improve the IP address' is_global/is_private document…
pythonGH-65056: Improve the IP address' is_global/is_private document…
pythonGH-65056: Improve the IP address' is_global/is_private document…
2 remaining items
pythongh-113171: pythongh-65056: Fix "private" (non-global) IP addres…
pythongh-113171: pythongh-65056: Fix "private" (non-global) IP addres…
[3.11] gh-113171: gh-65056: Fix "private" (non-global) IP address ran…
pythongh-113171: pythongh-65056: Fix "private" (non-global) IP addres…
pythongh-113171: pythongh-65056: Fix "private" (non-global) IP addres…
[3.10] gh-113171: gh-65056: Fix "private" (non-global) IP address ran…
[3.9] gh-113171: gh-65056: Fix "private" (non-global) IP address rang…
[3.8] gh-113171: gh-65056: Fix "private" (non-global) IP address rang…
CVE-2024-4032 Fix "private" (non-global) IP address ranges (pythonGH-…
CVE-2024-4032 Fix "private" (non-global) IP address ranges (pythonGH-…
CVE-2024-4032 Fix "private" (non-global) IP address ranges (pythonGH-…
CVE-2024-4032 Fix "private" (non-global) IP address ranges (pythonGH-…
00431: pythongh-113171: pythongh-65056: Fix "private" (non-global) IP…
00431: pythongh-113171: pythongh-65056: Fix "private" (non-global) IP…
00431: pythongh-113171: pythongh-65056: Fix "private" (non-global) IP…