Skip to content

Commit

Permalink
fix: default product type for system option
Browse files Browse the repository at this point in the history
  • Loading branch information
anthonyharrison committed Aug 1, 2024
1 parent 3798a2d commit 69ac517
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ Input:
Product:
--product-type {application,framework,library,container,operating-system,device,firmware,file}
type of product (default: application)
type of product
--product-name PRODUCT_NAME
name of product
--product-version PRODUCT_VERSION
Expand Down Expand Up @@ -145,7 +145,7 @@ The `--disto-namespace` option is used to specify a namespace to be included in
At least one of the `--input-file`, `--package` or `--system` options must be specified. If multiple options are specified, the `--input-file` option followed by the `--system` option will be assumed.

The `--product-type`, `--product-name`, `--product-version` and `--product-author` options allow the specification of the top level
component within the SBOM. These option only apply to CycloneDX SBOMs.
component within the SBOM. These option only apply to CycloneDX SBOMs. The default for product type is 'application' but it is always 'operating-system' if the `--system` option is specified.

The `--sbom` option is used to specify the format of the generated SBOM (the default is SPDX). The `--format` option
can be used to specify the formatting of the SBOM (the default is Tag Value format for a SPDX SBOM). JSON format is supported for both
Expand Down
12 changes: 9 additions & 3 deletions distro2sbom/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def main(argv=None):
"firmware",
"file",
],
help="type of product (default: application)",
help="type of product",
)
product_group.add_argument(
"--product-name",
Expand Down Expand Up @@ -216,6 +216,12 @@ def main(argv=None):
# Only json format valid for CycloneDX
bom_format = "json"

if args["system"]:
# Always operating system
product_type = "operating-system"
else:
product_type = args["product_type"]

if args["debug"]:
print("Distro type:", args["distro"])
print("Input file:", args["input_file"])
Expand All @@ -228,7 +234,7 @@ def main(argv=None):
print("SBOM type:", args["sbom"])
print("Format:", bom_format)
print("Output file:", args["output_file"])
print("Product Type", args["product_type"])
print("Product Type", product_type)
print("Product Name", args["product_name"])
print("Product Version", args["product_version"])
print("Product Author", args["product_author"])
Expand Down Expand Up @@ -288,7 +294,7 @@ def main(argv=None):
distro_sbom = SBOM()
sbom_doc = SBOMDocument()
sbom_doc.set_value("lifecycle", "operations")
sbom_doc.set_metadata_type(args["product_type"])
sbom_doc.set_metadata_type(product_type)
if args["product_name"] != "":
sbom_doc.set_name(args["product_name"])
if args["product_version"] != "":
Expand Down

0 comments on commit 69ac517

Please sign in to comment.