Skip to content

Commit 8f9eb2e

Browse files
bug: Correct handling of CycloneDX license data in XML documents
1 parent dfbee0a commit 8f9eb2e

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

sbomdiff/cyclonedx_parser.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,12 @@ def parse_cyclonedx_xml(self, sbom_file):
6666
if component_version is None:
6767
raise KeyError(f"Could not find version in {component}")
6868
version = component_version.text
69-
component_license = component.find(schema + "license")
70-
if component_license is None:
71-
license = "NOT FOUND"
72-
else:
73-
license = component_license.text
69+
license = "NOT FOUND"
70+
component_license = component.find(schema + "licenses")
71+
if component_license is not None:
72+
license_data = component_license.find(schema + "expression")
73+
if license_data is not None:
74+
license = license_data.text
7475
if version is not None:
7576
if package not in packages:
7677
packages[package] = [version, license]

0 commit comments

Comments
 (0)