Skip to content

Commit

Permalink
feat: Support displaying multiple PURL and CPE values (fixes anthonyh…
Browse files Browse the repository at this point in the history
  • Loading branch information
alcroito committed Aug 30, 2024
1 parent 207eba7 commit ac73bb0
Showing 1 changed file with 23 additions and 7 deletions.
30 changes: 23 additions & 7 deletions sbom2doc/generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,27 +145,43 @@ def generate_document(format, sbom_parser, filename, outfile, include_license):

# Show Purl and CPE information
sbom_document.paragraph("")
sbom_document.createtable(
["Name", "PURL", "CPE"], [12, 12, 15]
)
sbom_document.createtable(["Name", "PURL"], [12, 12])
for package in packages:
name = package.get("name", None)
purl = cpe = ""
purl = ""
external_info = package.get("externalreference", None)
at_least_one_found = False
if external_info is not None:
for reference in external_info:
if reference[1] == "purl":
try:
purl = reference[2]
at_least_one_found = True
sbom_document.addrow([name, purl])
except ValueError:
purl = ""
elif reference[1] in ["cpe22Type", "cpe23Type"]:
if not at_least_one_found:
sbom_document.addrow([name, purl])
sbom_document.showtable(widths=[5, 2, 2, 2, 2])

sbom_document.paragraph("")
sbom_document.createtable(["Name", "CPE"], [12, 12])
for package in packages:
name = package.get("name", None)
cpe = ""
external_info = package.get("externalreference", None)
at_least_one_found = False
if external_info is not None:
for reference in external_info:
if reference[1] in ["cpe22Type", "cpe23Type"]:
cpe = reference[2]
at_least_one_found = True
sbom_document.addrow([name, cpe])

sbom_document.addrow([name, purl, cpe])
if not at_least_one_found:
sbom_document.addrow([name, cpe])
sbom_document.showtable(widths=[5, 2, 2, 2, 2])


sbom_document.heading(1, "Component Type Summary")
sbom_document.createtable(["Type", "Count"], [25, 6])
#
Expand Down

0 comments on commit ac73bb0

Please sign in to comment.