From dc1abcb4ece4822e73e8353759c67c6c8150a141 Mon Sep 17 00:00:00 2001 From: "ssw@internet2.edu" Date: Fri, 6 Jan 2023 12:30:40 -0500 Subject: [PATCH] change to ensure that roa_asn and observed_asn are both ints before they are compared --- docker_container_version/main.py | 10 ++++++---- docker_container_version/new.sh | 9 +++++++++ docker_container_version/templates/index.html | 4 ++-- main.py | 4 +++- templates/index.html | 4 ++-- 5 files changed, 22 insertions(+), 9 deletions(-) create mode 100755 docker_container_version/new.sh diff --git a/docker_container_version/main.py b/docker_container_version/main.py index 896ce17..8d06484 100644 --- a/docker_container_version/main.py +++ b/docker_container_version/main.py @@ -66,7 +66,8 @@ def return_rov_status(roa_prefix, roa_maxlen, roa_asn, prefix, origin_asn): ip_prefix = ipaddress.ip_network(prefix) if not ip_prefix.subnet_of(roa_ip_prefix): return "error: prefix not covered by ROA" - if ip_prefix.subnet_of(roa_ip_prefix) and roa_maxlen >= ip_prefix.prefixlen and roa_asn == origin_asn: + + if ip_prefix.subnet_of(roa_ip_prefix) and int(roa_maxlen) >= int(ip_prefix.prefixlen) and int(roa_asn) == int(origin_asn): return "valid" else: return "invalid" @@ -125,18 +126,18 @@ def index(): roa_ip_prefix = roa_ip_prefix.strip() # Validate the IP prefix if not is_valid_prefix(roa_ip_prefix): - return 'Invalid IP prefix' + return f"\"{roa_ip_prefix}\" is an Invalid IP prefix" origin_asn = request.form['origin_asn'] origin_asn = origin_asn.strip() # Validate the origin ASN if not is_valid_asn(origin_asn): - return 'Invalid origin ASN' + return f"\"{origin_asn}\" is an Invalid origin ASN" roa_prefix_maxlength = request.form['prefix_maxlength'] roa_prefix_maxlength = roa_prefix_maxlength.strip() # Validate the prefix maxlength if not is_valid_prefix_maxlength(roa_ip_prefix, roa_prefix_maxlength): - return 'Invalid prefix maxlength' + return f"\"{roa_prefix_maxlength}\" is an Invalid prefix maxlength" roa_ip_prefix = request.form['ip_prefix'] roa_prefix_maxlength = int(request.form['prefix_maxlength']) @@ -154,5 +155,6 @@ def index(): return render_template('index.html') if __name__ == '__main__': + print("new version - ssw") app.run(port=8000, host='0.0.0.0') diff --git a/docker_container_version/new.sh b/docker_container_version/new.sh new file mode 100755 index 0000000..9361314 --- /dev/null +++ b/docker_container_version/new.sh @@ -0,0 +1,9 @@ +cp ../main.py . +cp ../templates/* templates +# docker build -t roa-checker:latest . +docker buildx build \ +--platform linux/amd64,linux/arm64,linux/arm/v7 \ +-t stevenisfine/roa_checker:latest \ +--push \ +. + diff --git a/docker_container_version/templates/index.html b/docker_container_version/templates/index.html index 3ae2dc5..305a88d 100644 --- a/docker_container_version/templates/index.html +++ b/docker_container_version/templates/index.html @@ -45,9 +45,9 @@

This app queries the stat.ripe.net to determine if a RPKI-ROA created with the following information would likely agree (i.e., not evaluate as invalid) for routes currently seen in the Internet

- + - + diff --git a/main.py b/main.py index a9f3c82..8d06484 100644 --- a/main.py +++ b/main.py @@ -66,7 +66,8 @@ def return_rov_status(roa_prefix, roa_maxlen, roa_asn, prefix, origin_asn): ip_prefix = ipaddress.ip_network(prefix) if not ip_prefix.subnet_of(roa_ip_prefix): return "error: prefix not covered by ROA" - if ip_prefix.subnet_of(roa_ip_prefix) and roa_maxlen >= ip_prefix.prefixlen and roa_asn == origin_asn: + + if ip_prefix.subnet_of(roa_ip_prefix) and int(roa_maxlen) >= int(ip_prefix.prefixlen) and int(roa_asn) == int(origin_asn): return "valid" else: return "invalid" @@ -154,5 +155,6 @@ def index(): return render_template('index.html') if __name__ == '__main__': + print("new version - ssw") app.run(port=8000, host='0.0.0.0') diff --git a/templates/index.html b/templates/index.html index 3ae2dc5..305a88d 100644 --- a/templates/index.html +++ b/templates/index.html @@ -45,9 +45,9 @@

This app queries the stat.ripe.net to determine if a RPKI-ROA created with the following information would likely agree (i.e., not evaluate as invalid) for routes currently seen in the Internet

- + - +