networktocode / netutils

Python library that is a collection of functions and objects for common network automation tasks.
https://netutils.readthedocs.io/
Other
214 stars 48 forks source link

Incorrect response when using 'is_netmask` with inverse netmask. #548

Open jdrew82 opened 2 months ago

jdrew82 commented 2 months ago

Environment

Expected Behavior

Expected to get a True response when passing "0.31.255.255" to is_netmask().

Observed Behavior

It was returned as False:

In [1]: from netutils.ip import is_netmask

In [2]: is_netmask("0.31.255.255")
Out[2]: False

Steps to Reproduce

  1. Import is_netmask() in REPL.
  2. Pass inverse/wildcard netmasks to the is_netmask().
  3. See results.
jdrew82 commented 2 months ago

This also means the netmask_to_cidr() function doesn't work as the is_netmask() returns False. If you test what's returned with that function ignoring the is_netmask() check you get the CIDR returned when using an inverse netmask.