Conversion between typical CIDR ranges and the ranges allowed by AWS WAF:
AWS WAF supports /8, /16, /24, and /32 IPv4 address ranges and /16, /24, /32, /56, /64, and /128 IPv6 address ranges
$ ./converter.py -h
usage: converter.py [-h] cidr_range
Converts CIDR ranges into AWS WAF IP Set allowed ranges
positional arguments:
cidr_range eg. 192.168.0.0/23
optional arguments:
-h, --help show this help message and exit
$ ./converter.py 192.168.0.0/23
192.168.0.0/24
192.168.1.0/24
Supports both Python 2.7 and 3.6 (others may run but no tests are ran against them).
For Python2 you will need to install some dependencies:
pip install -r requirements.txt
These are backported modules from Python3's Standard Library so Python3 has no such dependencies.
To run all the tests for both Python2.7 and 3.6 just run:
tox
Obviously you will need tox
available but this will install all dependencies for each environment in a virtual environment.
There is a pre-commit hook available that will automatically run the tests for you. Simply copy it into your .git/hooks
folder to install it:
cp pre-commit .git/hooks/