Skip to content

Commit

Permalink
fix: check return on re.search in canonical_convert (#1643)
Browse files Browse the repository at this point in the history
addresses #1639

re.search returns `None` on failure, updating to indicate the version is
`UNKNOWN` when this occurs and generating a log message
  • Loading branch information
wyattearp authored Apr 26, 2022
1 parent abffa0d commit ec69e35
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion cve_bin_tool/cve_scanner.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,13 @@ def canonical_convert(
else:
# Handle a.b.c<string> e.g. 1.20.9rel1
pv = re.search(r"\d[.\d]*", product_info.version)
parsed_version = parse_version(pv.group(0))
if pv is None:
parsed_version = "UNKNOWN"
self.logger.warn(
f"error parsing {product_info.vendor}.{product_info.product} v{product_info.version} - manual inspection required"
)
else:
parsed_version = parse_version(pv.group(0))
return parsed_version, version_between

def affected(self):
Expand Down

0 comments on commit ec69e35

Please sign in to comment.