Skip to content

Commit

Permalink
refactor: remove unecessary ifs
Browse files Browse the repository at this point in the history
  • Loading branch information
terriko committed Feb 10, 2023
1 parent fd3d2ac commit 40ca8c9
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions cve_bin_tool/cve_scanner.py
Original file line number Diff line number Diff line change
Expand Up @@ -338,16 +338,13 @@ def parse_version(self, version_string: str) -> Tuple[Version]:
version_string = re.sub("_", ".", version_string)

# handle leading product name like curl-7.57.0 by truncating
if re.match("[a-zA-Z]*-", version_string):
version_string = re.sub("[a-zA-Z]*-", "", version_string)
version_string = re.sub("^[a-zA-Z]*-", "", version_string)

# Or just convert the - to a . for cases like `5-1.6`
if "-" in version_string:
version_string = re.sub("-", ".", version_string)
version_string = re.sub("-", ".", version_string)

# handle trailing letters a la '1.6.3.kdc' by truncating
if re.match(r"\.[a-zA-Z]*$", version_string):
version_string = re.sub(r"\.[a-zA-Z]*$", "", version_string)
version_string = re.sub(r"\.[a-zA-Z]*$", "", version_string)

# Otherwise just try to parse it with packaging's parse
parsed_version = packaging_parse(version_string)
Expand Down

0 comments on commit 40ca8c9

Please sign in to comment.