Skip to content

Commit

Permalink
FIX: Fixes update-database script on the last few days of a month.
Browse files Browse the repository at this point in the history
  • Loading branch information
gethvi committed Oct 26, 2021
1 parent 6c89013 commit e3a1d7a
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions intelmq/bots/experts/asn_lookup/expert.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,16 @@ def update_database(cls):
if not months:
sys.exit("Database update failed. Couldn't find the latest database update.")

url += str(months[0]) + "/RIBS/"
response = session.get(url)
pattern = re.compile(r"href=\"(rib\.\d{8}\.\d{4}\.bz2)\"")
days = pattern.findall(response.text)
days.sort(reverse=True)
# routeviews website creates next month's directory on 28th of the current month
# therefore on 28th, 29th, 30th, 31st it's necessary to find the second highest month directory
for i in range(2):
url += str(months[i]) + "/RIBS/"
response = session.get(url)
pattern = re.compile(r"href=\"(rib\.\d{8}\.\d{4}\.bz2)\"")
days = pattern.findall(response.text)
days.sort(reverse=True)
if days:
break

if not days:
sys.exit("Database update failed. Couldn't find the latest database update.")
Expand Down

0 comments on commit e3a1d7a

Please sign in to comment.