Skip to content

fix(cve_scanner): fix canonical_convert #1519

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 13, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions cve_bin_tool/cve_scanner.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@
from collections import defaultdict
from logging import Logger
from string import ascii_lowercase
from typing import DefaultDict, Dict, List
from typing import DefaultDict, Dict, List, Tuple, Union

from pkg_resources import parse_version
from packaging.version import LegacyVersion, Version
from packaging.version import parse as parse_version
from rich.console import Console

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

def canonical_convert(self, product_info: ProductInfo) -> str:
version_between = ""
VersionType = Union[Version, LegacyVersion]

def canonical_convert(
self, product_info: ProductInfo
) -> Tuple[VersionType, VersionType]:
version_between = parse_version("")
if product_info.version == "":
return product_info.version, version_between
return parse_version(product_info.version), version_between
if product_info.product == "openssl":
pv = re.search(r"\d[.\d]*[a-z]?", product_info.version)
version_between = parse_version(self.openssl_convert(pv.group(0)))
Expand Down