From af2492f489ee93053beb8424f90866f46d9ce1a6 Mon Sep 17 00:00:00 2001 From: anthonyharrison Date: Tue, 13 Feb 2024 09:49:39 +0000 Subject: [PATCH] feat: Simple SPDX to CycloneDX file converter --- examples/spdx2cdx.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 examples/spdx2cdx.py diff --git a/examples/spdx2cdx.py b/examples/spdx2cdx.py new file mode 100644 index 0000000..6e36c18 --- /dev/null +++ b/examples/spdx2cdx.py @@ -0,0 +1,19 @@ +# Copyright (C) 2024 Anthony Harrison +# SPDX-License-Identifier: Apache-2.0 + +import sys +from lib4sbom.parser import SBOMParser +from lib4sbom.generator import SBOMGenerator + +# Simple SPDX SBOM to CycloneDX converter + +# Set up SBOM parser +test_parser = SBOMParser() +# Load SBOM - will autodetect SBOM type +test_parser.parse_file(sys.argv[1]) + +# Set up SPDX-JSON generator +test_generator = SBOMGenerator(False, sbom_type="cyclonedx", format="json") +# Generate sbom in JSON format to console (default) +test_generator.generate("ACMEApp", test_parser.get_sbom()) +