Skip to content

Commit c4ec1fa

Browse files
fix: Added None checks for parsed purls (fixes #3478) (#3490)
fixes #3478
1 parent 720e9f9 commit c4ec1fa

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

cve_bin_tool/sbom_manager/__init__.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,9 @@ def parse_sbom(self):
123123
if ref[1] == "purl":
124124
# Process purl identifier
125125
purl_info = PackageURL.from_string(ref[2]).to_dict()
126-
modules.append([purl_info["name"], purl_info["version"]])
127-
purl_found = True
126+
if purl_info["name"] and purl_info["version"]:
127+
modules.append([purl_info["name"], purl_info["version"]])
128+
purl_found = True
128129
if not purl_found:
129130
if package.get("version") is not None:
130131
modules.append([package["name"], package["version"]])

test/sbom/cyclonedx_mixed_test.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,12 @@
3333
"name": "GLIBC",
3434
"version": "2.11.1",
3535
"purl": "pkg:maven/org.gnu.glibc/glibc@2.11.1"
36+
},
37+
{
38+
"name": "invalid_purl_package",
39+
"version": "1.1.0",
40+
"type": "library",
41+
"purl": "pkg:xxx/xxx/xxx"
3642
}
3743
]
3844
}

0 commit comments

Comments
 (0)