From c7f77d105701a0160059969a1a36d54d9c7900f3 Mon Sep 17 00:00:00 2001 From: Matt Griswold Date: Wed, 15 Apr 2020 12:06:09 +0000 Subject: [PATCH] better range check for unallocated ASNs for #9 --- CHANGELOG.yaml | 3 ++- rdap/objects.py | 9 ++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.yaml b/CHANGELOG.yaml index 44c09a7..723d671 100644 --- a/CHANGELOG.yaml +++ b/CHANGELOG.yaml @@ -42,6 +42,7 @@ Unreleased: added: [] changed: [] deprecated: [] - fixed: [] + fixed: + - better range check for unallocated ASNs removed: [] security: [] diff --git a/rdap/objects.py b/rdap/objects.py index 205934f..ed497db 100644 --- a/rdap/objects.py +++ b/rdap/objects.py @@ -1,4 +1,4 @@ -from builtins import object +from rdap.exceptions import RdapNotFoundError class RdapObject(object): @@ -139,6 +139,13 @@ class RdapAsn(RdapObject): """ def __init__(self, data, rdapc=None): + # check for ASN range, meaning it's delegated and unallocated + if data: + start = data.get("startAutnum", None) + end = data.get("endAutnum", None) + if start and end and start != end: + raise RdapNotFoundError("AS{} returned a block, so it is not allocated".format(start)) + super().__init__(data, rdapc)