Skip to content

Commit

Permalink
feat: Report type of component
Browse files Browse the repository at this point in the history
  • Loading branch information
anthonyharrison committed Aug 17, 2023
1 parent 298faeb commit 4796d0e
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions sbom2doc/generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ def generate_document(format, sbom_parser, filename, outfile, include_license):
packages_valid = True
relationships_valid = len(relationships) > 0
sbom_licenses = []
sbom_components = []
if len(files) > 0:

sbom_document.heading(1, "File Summary")
Expand All @@ -80,19 +81,21 @@ def generate_document(format, sbom_parser, filename, outfile, include_license):

sbom_document.heading(1, "Package Summary")
sbom_document.createtable(
["Name", "Version", "Supplier", "License"], [12, 8, 8, 12]
["Name", "Version", "Type", "Supplier", "License"], [12, 8, 8, 8, 12]
)
for package in packages:
# Minimum elements are ID, Name, Version, Supplier
id = package.get("id", None)
name = package.get("name", None)
version = package.get("version", None)
type = package.get("type", None)
supplier = package.get("supplier", None)
license = package.get("licenseconcluded", "NOT KNOWN")
if license != "NOT KNOWN" and license_info.deprecated(license):
license = f"{license} (Deprecated)"
sbom_licenses.append(license)
sbom_document.addrow([name, version, supplier, license])
sbom_components.append(type)
sbom_document.addrow([name, version, type, supplier, license])
if (
id is None
or name is None
Expand Down Expand Up @@ -127,6 +130,17 @@ def generate_document(format, sbom_parser, filename, outfile, include_license):
sbom_document.addrow([name, version, ecosystem, download, copyright])
sbom_document.showtable(widths=[5, 2, 2, 2, 2])

sbom_document.heading(1, "Component Type Summary")
sbom_document.createtable(["Type", "Count"], [25, 6])
#
# Create an empty dictionary
freq = {}
for items in sorted(sbom_components):
freq[items] = sbom_components.count(items)
for key, value in freq.items():
sbom_document.addrow([key, str(value)])
sbom_document.showtable(widths=[10, 4])

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

0 comments on commit 4796d0e

Please sign in to comment.