|
8 | 8 | from collections import defaultdict
|
9 | 9 | from logging import Logger
|
10 | 10 | from string import ascii_lowercase
|
11 |
| -from typing import DefaultDict, Dict, List |
| 11 | +from typing import DefaultDict, Dict, List, Tuple, Union |
12 | 12 |
|
13 |
| -from pkg_resources import parse_version |
| 13 | +from packaging.version import LegacyVersion, Version |
| 14 | +from packaging.version import parse as parse_version |
14 | 15 | from rich.console import Console
|
15 | 16 |
|
16 | 17 | from cve_bin_tool.cvedb import DBNAME, DISK_LOCATION_DEFAULT
|
@@ -251,10 +252,14 @@ def openssl_convert(self, version: str) -> str:
|
251 | 252 | version = f"{version[:-1]}.{self.ALPHA_TO_NUM[last_char]}"
|
252 | 253 | return version
|
253 | 254 |
|
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("") |
256 | 261 | if product_info.version == "":
|
257 |
| - return product_info.version, version_between |
| 262 | + return parse_version(product_info.version), version_between |
258 | 263 | if product_info.product == "openssl":
|
259 | 264 | pv = re.search(r"\d[.\d]*[a-z]?", product_info.version)
|
260 | 265 | version_between = parse_version(self.openssl_convert(pv.group(0)))
|
|
0 commit comments