Skip to content

Commit a4566e3

Browse files
Allow non-standard license in SBOM generation (#144)
* Allow non-standard license * Remove commit being succesful
1 parent b62af78 commit a4566e3

2 files changed

Lines changed: 32 additions & 1 deletion

File tree

release/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ runs:
126126
git add "$HEADER_FILE"
127127
fi
128128
129-
git commit -m '[AUTO][RELEASE]: Update version numbers' || true
129+
git commit -m '[AUTO][RELEASE]: Update version numbers'
130130
131131
- name: Push release preparation branch
132132
shell: bash

sbom-generator/sbom_generator.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
File,
2424
ChecksumAlgorithm,
2525
Checksum,
26+
ExtractedLicensingInfo,
2627
)
2728
from spdx_tools.common.spdx_licensing import spdx_licensing
2829
from spdx_tools.spdx.writer.write_anything import write_file
@@ -220,6 +221,35 @@ def generate_sbom(
220221
packages = []
221222
relationships = []
222223
files = []
224+
extracted_licensing_info = []
225+
226+
# Collect custom licenses that need to be extracted
227+
custom_licenses = set()
228+
for file_info in included_file_info.values():
229+
lic = file_info.get("license", SpdxNoAssertion())
230+
if not isinstance(lic, SpdxNoAssertion) and lic.startswith("LicenseRef-"):
231+
custom_licenses.add(lic)
232+
233+
if "dependencies" in manifest:
234+
for dep in manifest["dependencies"]:
235+
lic = dep["license"]
236+
if not isinstance(lic, SpdxNoAssertion) and lic.startswith("LicenseRef-"):
237+
custom_licenses.add(lic)
238+
239+
if "testDependencies" in manifest:
240+
for dep in manifest["testDependencies"]:
241+
lic = dep["license"]
242+
if not isinstance(lic, SpdxNoAssertion) and lic.startswith("LicenseRef-"):
243+
custom_licenses.add(lic)
244+
245+
# Create extracted licensing info for custom licenses
246+
for custom_lic in custom_licenses:
247+
extracted_licensing_info.append(
248+
ExtractedLicensingInfo(
249+
license_id=custom_lic,
250+
extracted_text="See project repository for license details"
251+
)
252+
)
223253

224254
# Generate output filenames based on package info
225255
output_files = [
@@ -481,6 +511,7 @@ def generate_sbom(
481511
packages=packages,
482512
files=files,
483513
relationships=relationships,
514+
extracted_licensing_info=extracted_licensing_info,
484515
)
485516

486517
write_file(document, output_path, validate=True)

0 commit comments

Comments
 (0)