Skip to content

Commit 117ad88

Browse files
committed
fix(cve_scanner): fix canonical_convert
1 parent 8c1f773 commit 117ad88

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

cve_bin_tool/cve_scanner.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@
88
from collections import defaultdict
99
from logging import Logger
1010
from string import ascii_lowercase
11-
from typing import DefaultDict, Dict, List
11+
from typing import DefaultDict, Dict, List, Tuple, Union
1212

13-
from pkg_resources import parse_version
13+
from packaging.version import LegacyVersion, Version
14+
from packaging.version import parse as parse_version
1415
from rich.console import Console
1516

1617
from cve_bin_tool.cvedb import DBNAME, DISK_LOCATION_DEFAULT
@@ -251,10 +252,14 @@ def openssl_convert(self, version: str) -> str:
251252
version = f"{version[:-1]}.{self.ALPHA_TO_NUM[last_char]}"
252253
return version
253254

254-
def canonical_convert(self, product_info: ProductInfo) -> str:
255-
version_between = ""
255+
VersionType = Union[Version, LegacyVersion]
256+
257+
def canonical_convert(
258+
self, product_info: ProductInfo
259+
) -> Tuple[VersionType, VersionType]:
260+
version_between = parse_version("")
256261
if product_info.version == "":
257-
return product_info.version, version_between
262+
return parse_version(product_info.version), version_between
258263
if product_info.product == "openssl":
259264
pv = re.search(r"\d[.\d]*[a-z]?", product_info.version)
260265
version_between = parse_version(self.openssl_convert(pv.group(0)))

0 commit comments

Comments
 (0)