Skip to content

Commit

Permalink
bug: extract license from evidence section if present
Browse files Browse the repository at this point in the history
  • Loading branch information
anthonyharrison committed Nov 15, 2022
1 parent 548d9ae commit a980cd9
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions sbomdiff/cyclonedx_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,13 @@ def parse_cyclonedx_json(self, sbom_file):
package = d["name"]
version = d["version"]
license = "NOT FOUND"
license_data = None
# Multiple ways of defining license data
if "licenses" in d and len(d["licenses"]) > 0:
license_data = d["licenses"][0]
elif "evidence" in d and len(d["evidence"]["licenses"]) > 0:
license_data = d["evidence"]["licenses"][0]
if license_data is not None:
if "license" in license_data:
if "id" in license_data["license"]:
license = license_data["license"]["id"]
Expand Down

0 comments on commit a980cd9

Please sign in to comment.