Skip to content
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

fix: improved cpe parsing in sbom code #4082

Merged
merged 2 commits into from
Apr 25, 2024
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
6 changes: 4 additions & 2 deletions cve_bin_tool/sbom_manager/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,8 @@ def decode_cpe22(self, cpe22) -> (str | None, str | None, str | None):

"""

cpe = cpe22.split(":")
# split on `:` only if it's not escaped
cpe = re.split(r"(?<!\\):", cpe22)
terriko marked this conversation as resolved.
Show resolved Hide resolved
vendor, product, version = cpe[2], cpe[3], cpe[4]
# Return available data, convert empty fields to None
return [vendor or None, product or None, version or None]
Expand All @@ -361,7 +362,8 @@ def decode_cpe23(self, cpe23) -> (str | None, str | None, str | None):

"""

cpe = cpe23.split(":")
# split on `:` only if it's not escaped
cpe = re.split(r"(?<!\\):", cpe23)
terriko marked this conversation as resolved.
Show resolved Hide resolved
vendor, product, version = cpe[3], cpe[4], cpe[5]
# Return available data, convert empty fields to None
return [vendor or None, product or None, version or None]
Expand Down
Loading