classification
Title: ipaddress.IPv4Network allows prefix > 32
Type: behavior Stage: patch review
Components: Library (Lib) Versions: Python 3.7
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: John Florian, jedwards, matrixise, pitrou, remi.lapeyre
Priority: normal Keywords: patch

Created on 2019-02-13 16:13 by John Florian, last changed 2019-03-05 16:59 by jedwards.

Pull Requests
URL Status Linked Edit
PR 11844 open matrixise, 2019-02-13 20:45
Messages (4)
msg335460 - (view) Author: John Florian (John Florian) Date: 2019-02-13 16:13
I wanted a simple is_valid_ipv4_network() function, so I wrote one and a bunch of unit tests where I discovered that I can legally:

>>> n = IPv4Network(('192.168.123.234', 12345678))
>>> n
IPv4Network('192.168.123.234/12345678')
>>> n.prefixlen
12345678
>>> n.max_prefixlen
32

I assume this is a bug.
msg335475 - (view) Author: Stéphane Wirtel (matrixise) * (Python triager) Date: 2019-02-13 20:47
I proposed my PR but I prefer a review because in the code of ipaddress, there is a function for the validation of an address with the netmask. Maybe we could use this function and try to refactor/improve the current code.
msg337228 - (view) Author: Rémi Lapeyre (remi.lapeyre) * Date: 2019-03-05 16:44
Hi @maxtrixise, thanks for PR,

> there is a function for the validation of an address with the netmask

Which one do you want to use?
msg337230 - (view) Author: James Edwards (jedwards) * Date: 2019-03-05 16:59
It may be worth also addressing the fact that IPv6Network makes no restriction on it's netmask (when specified as a tuple).
History
Date User Action Args
2019-03-05 16:59:48jedwardssetnosy: + jedwards
messages: + msg337230
2019-03-05 16:44:02remi.lapeyresetmessages: + msg337228
2019-02-13 20:47:15matrixisesetnosy: + matrixise
messages: + msg335475
2019-02-13 20:45:06matrixisesetkeywords: + patch
stage: test needed -> patch review
pull_requests: + pull_request11875
2019-02-13 17:06:13SilentGhostsetnosy: + pitrou

type: behavior
components: + Library (Lib)
stage: test needed
2019-02-13 16:14:52remi.lapeyresetnosy: + remi.lapeyre
2019-02-13 16:13:55John Floriancreate