secynic / ipwhois

Retrieve and parse whois data for IPv4 and IPv6 addresses
https://ipwhois.readthedocs.io/en/latest
BSD 2-Clause "Simplified" License
555 stars 121 forks source link

`IndexError: list index out of range` happens sometimes on lookup_rdap() #334

Open nil0x42 opened 1 week ago

nil0x42 commented 1 week ago

Here is a traceback:

Traceback (most recent call last):
  File "/usr/local/lib/python3.10/dist-packages/ipwhois/asn.py", line 260, in parse_fields_whois
    ret = {'asn_registry': temp[4].strip(' \n')}
IndexError: list index out of range
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/home/user/scripts/ipwhois/resolveIPWhois.py", line 364, in <module>
    for cidr, whois in resolver.process_ip(ip):
  File "/home/user/scripts/ipwhois/resolveIPWhois.py", line 58, in process_ip
    res = self._lookup(ipw.lookup_rdap)
  File "/home/user/scripts/ipwhois/resolveIPWhois.py", line 108, in _lookup
    res = self._lookup_retry(method)
  File "/home/user/scripts/ipwhois/resolveIPWhois.py", line 88, in _lookup_retry
    return method()
  File "/usr/local/lib/python3.10/dist-packages/ipwhois/ipwhois.py", line 299, in lookup_rdap
    asn_data = self.ipasn.lookup(
  File "/usr/local/lib/python3.10/dist-packages/ipwhois/asn.py", line 496, in lookup
    asn_data = self.parse_fields_whois(
  File "/usr/local/lib/python3.10/dist-packages/ipwhois/asn.py", line 281, in parse_fields_whois
    raise ASNParseError('Parsing failed for "{0}" with exception: {1}.'
ipwhois.exceptions.ASNParseError: Parsing failed for "" with exception: list index out of range.

It happens unfrequently, but happens. I tried to reproduce the error with the impacted IPs, but every time i retried manually it worked.

Thank you for this wonderful library