From 1e72cea89abe51650aaae323d4e6010790fdff69 Mon Sep 17 00:00:00 2001 From: Marc Wrobel Date: Thu, 15 Aug 2024 10:43:09 +0200 Subject: [PATCH] [pan-os] Add automation for versions retrieval Based on https://github.com/mrjcap/panos-versions/. Closes #370. --- src/common/dates.py | 1 + src/pan-os.py | 11 +++++++++++ 2 files changed, 12 insertions(+) create mode 100644 src/pan-os.py diff --git a/src/common/dates.py b/src/common/dates.py index 714fafe03..c24c2fe73 100644 --- a/src/common/dates.py +++ b/src/common/dates.py @@ -43,6 +43,7 @@ def parse_datetime(text: str, formats: list[str] = frozenset([ "%Y-%m-%d %H:%M:%S %z", # 2023-05-01 08:32:34 +0900 "%Y-%m-%dT%H:%M:%S%z", # 2023-05-01T08:32:34+0900 "%Y-%m-%dT%H:%M:%S.%f%z", # 2023-05-01T08:32:34.123456Z + "%Y/%m/%d %H:%M:%S", # 2023/05/01 08:32:34 "%a %d %b %Y %H:%M:%S %Z", # Wed, 01 Jan 2020 00:00:00 GMT ]), to_utc: bool = True) -> datetime: """Parse a given text representing a datetime using a list of formats, diff --git a/src/pan-os.py b/src/pan-os.py new file mode 100644 index 000000000..be08ec599 --- /dev/null +++ b/src/pan-os.py @@ -0,0 +1,11 @@ +from common import dates, http, releasedata + +"""Fetches pan-os versions from https://github.com/mrjcap/panos-versions/.""" + +with releasedata.ProductData("pan-os") as product_data: + versions = http.fetch_url("https://raw.githubusercontent.com/mrjcap/panos-versions/master/PaloAltoVersions.json").json() + + for version in versions: + name = version['version'] + date = dates.parse_datetime(version['released-on']) + product_data.declare_version(name, date)