Skip to content

Commit

Permalink
feat: Simple SPDX to CycloneDX file converter
Browse files Browse the repository at this point in the history
  • Loading branch information
anthonyharrison committed Feb 13, 2024
1 parent c2fb12a commit af2492f
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions examples/spdx2cdx.py
Original file line number Diff line number Diff line change
@@ -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())

0 comments on commit af2492f

Please sign in to comment.