following is my experiment with the wrong CIDR in python console:
>>> net = ip.IPNetwork('10.0.0.3/24')
>>> net.cidr
IPNetwork('10.0.0.0/24')
>>> net.netmask
IPAddress('255.255.255.0')
the conclusion is we need enhance the validation:
def _validate_subnet(data, valid_values=None):
try: netaddr.IPNetwork(_validate_no_whitespace(data))
if len(data.split('/')) == 2:
return
except Exception:
pass
following is my experiment with the wrong CIDR in python console: '10.0.0. 3/24') '10.0.0. 0/24') '255.255. 255.0')
>>> net = ip.IPNetwork(
>>> net.cidr
IPNetwork(
>>> net.netmask
IPAddress(
the conclusion is we need enhance the validation: subnet( data, valid_values=None):
netaddr. IPNetwork( _validate_ no_whitespace( data)) split(' /')) == 2:
def _validate_
try:
if len(data.
return
except Exception:
pass