From cc624a7cd4e3b0f69546be8b48101c80fc1e49f0 Mon Sep 17 00:00:00 2001 From: Nemo Date: Fri, 16 Dec 2022 16:40:11 +0530 Subject: [PATCH] [pan] Fix new date ingestion --- releases/pan-cortex-xdr.json | 10 ++++++++++ src/palo-alto-networks.py | 20 +++++++++++++------- 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/releases/pan-cortex-xdr.json b/releases/pan-cortex-xdr.json index 883409bb..5a3df04a 100644 --- a/releases/pan-cortex-xdr.json +++ b/releases/pan-cortex-xdr.json @@ -1,4 +1,14 @@ { + "3.1": "2014-09-03", + "3.2": "2015-03-31", + "3.3": "2015-11-10", + "3.4": "2016-08-21", + "4.0": "2017-04-05", + "4.1": "2017-09-15", + "4.2": "2018-06-25", + "5.0": "2018-03-19", + "6.0": "2019-02-26", + "6.1": "2019-07-02", "7.0": "2019-12-04", "7.1": "2020-04-22", "7.2": "2020-09-07", diff --git a/src/palo-alto-networks.py b/src/palo-alto-networks.py index 0b4efe6e..c03b4644 100644 --- a/src/palo-alto-networks.py +++ b/src/palo-alto-networks.py @@ -1,6 +1,7 @@ import json import urllib.request import datetime +import re from bs4 import BeautifulSoup URL = "https://www.paloaltonetworks.com/services/support/end-of-life-announcements/end-of-life-summary" @@ -28,14 +29,19 @@ def update_releases(html_identifier, file): version = version.removesuffix("-(cortex-xdr-agent)") version = version.removesuffix("-(vm-series-only)") version = version.removesuffix("-(panorama-only)") - try: - month, date, year = td_list[1].get_text().split("/") - abs_date = f"{year}-{month:0>2}-{date:0>2}" - except Exception: - date = datetime.datetime.strptime(td_list[1].get_text(), "%B %d, %Y") - abs_date = date.strftime("%Y-%m-%d") + if len(td_list) > 1 and version != "": + # Date formats differ between different products + try: + month, date, year = td_list[1].get_text().split("/") + abs_date = f"{year}-{month:0>2}-{date:0>2}" + except Exception: + # A few dates have 1st, 2nd, 4th etc. Fix that: + d = td_list[1].get_text() + d = re.sub(r'(\w+) (\d{1,2})(?:\w{2}), (\d{4})', r'\1 \2, \3', d) + date = datetime.datetime.strptime(d, "%B %d, %Y") + abs_date = date.strftime("%Y-%m-%d") - versions[version] = abs_date + versions[version] = abs_date with open("releases/%s.json" % file, "w") as f: f.write(json.dumps(versions, indent=2))