From 255ae2a24e1baea3ddc2767fb3ac29d491af7c7f Mon Sep 17 00:00:00 2001 From: tristanlatr <19967168+tristanlatr@users.noreply.github.com> Date: Mon, 4 Dec 2023 10:29:38 -0500 Subject: [PATCH] Fix get version (#28) --- burpa/__version__.py | 2 +- burpa/_burp_rest_api_client.py | 4 ++-- burpa/_utils.py | 15 ++++++++------- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/burpa/__version__.py b/burpa/__version__.py index 1c1bc90..7495250 100644 --- a/burpa/__version__.py +++ b/burpa/__version__.py @@ -1,2 +1,2 @@ __author__ = 'Adel "0x4d31" Karimi, and other contributors' -__version__ = '0.3.10' +__version__ = '0.3.11' diff --git a/burpa/_burp_rest_api_client.py b/burpa/_burp_rest_api_client.py index 7b1cd55..049248f 100644 --- a/burpa/_burp_rest_api_client.py +++ b/burpa/_burp_rest_api_client.py @@ -134,7 +134,7 @@ def proxy_uri(self) -> str: return f"{self.proxy_url}:{self.api_port}" @property - def rest_api_version(self) -> Tuple[int,int,int]: + def rest_api_version(self) -> Tuple[int,...]: """The version of the burp-rest-api Extension""" try: r = self.request('versions') @@ -144,7 +144,7 @@ def rest_api_version(self) -> Tuple[int,int,int]: return get_version(r.json()['extensionVersion']) @property - def burp_version(self) -> Tuple[int,int,int]: + def burp_version(self) -> Tuple[int,...]: """The version of Burp""" try: r = self.request('versions') diff --git a/burpa/_utils.py b/burpa/_utils.py index 689585c..ba43e9c 100644 --- a/burpa/_utils.py +++ b/burpa/_utils.py @@ -123,7 +123,7 @@ def is_timenow_between(begin_time: time, end_time: time) -> bool: else: # When the time crosses midnight return check_time >= begin_time or check_time <= end_time -def get_version(s:str) -> Tuple[int, int, int]: +def get_version(s:str) -> Tuple[int, ...]: """ Parse a version string like .. into a tuple of ints. """ @@ -134,18 +134,18 @@ def get_version(s:str) -> Tuple[int, int, int]: try: v = int(p) except: - v = 0 + if intparts: + v = 0 + else: + continue intparts.append(v) if 3-len(intparts)>0: for _ in range(3-len(intparts)): intparts.append(0) - elif len(intparts)>3: - for _ in range(len(intparts)-3): - intparts.pop(0) - assert len(intparts)==3 + return tuple(intparts) # type: ignore _tag = re.compile('<[^<]+?>') @@ -158,5 +158,6 @@ def strip_tags(html:str) -> str: assert get_version("2.2.0") == (2,2,0) assert get_version("2") == (2,0,0) assert get_version("Burp Suite Professional.2022.6.1") == (2022,6,1) + assert get_version("Burp Suite Professional.2022.6.1.1") == (2022,6,1,1) assert get_version("Burp Suite Professional.2022.thing.1") == (2022,0,1) - assert get_version("0.2022.6.1") == (2022,6,1) \ No newline at end of file + assert get_version("0.2022.6.1") == (0, 2022,6,1) \ No newline at end of file