Skip to content

Commit 4826df8

Browse files
committed
Use cyclonedx 1.6 schema (bump to 1.7.0)
1 parent 313322d commit 4826df8

5 files changed

Lines changed: 23 additions & 24 deletions

File tree

CHANGELOG.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ Release 0.11.0 (unreleased)
55
* Don't show animation when running in CI (#702)
66
* Improve logic for creating Purls in SBoM (#780)
77
* Add External VCS reference to SBoM if possible (#780)
8+
* Use CycloneDX schema version 1.6 (#542)
89
* Add security policy (#784)
910
* Add provenance / release attestation to pypi package (#784)
1011

dfetch/reporting/sbom_reporter.py

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,12 @@
1515
An fetched project generates an sbom
1616
"""
1717

18-
import json
19-
from typing import cast
20-
2118
from cyclonedx.model import ExternalReference, ExternalReferenceType, Tool, XsUri
2219
from cyclonedx.model.bom import Bom
2320
from cyclonedx.model.component import Component, ComponentType
2421
from cyclonedx.model.license import LicenseExpression
25-
from cyclonedx.output import get_instance
26-
from cyclonedx.output.json import Json
27-
from cyclonedx.schema import OutputFormat
22+
from cyclonedx.output import make_outputter
23+
from cyclonedx.schema import OutputFormat, SchemaVersion
2824

2925
import dfetch.util.purl
3026
from dfetch.manifest.project import ProjectEntry
@@ -94,13 +90,12 @@ def dump_to_file(self, outfile: str) -> bool:
9490
output_format = OutputFormat(
9591
OutputFormat.XML if outfile.endswith(".xml") else OutputFormat.JSON
9692
)
97-
outputter = cast(Json, get_instance(bom=self._bom, output_format=output_format))
98-
99-
parsed = json.loads(outputter.output_as_string())
100-
outputter._json_output = ( # pylint: disable=protected-access # type: ignore
101-
json.dumps(parsed, indent=4)
93+
outputter = make_outputter(
94+
bom=self._bom,
95+
output_format=output_format,
96+
schema_version=SchemaVersion.V1_6,
10297
)
10398

104-
outputter.output_to_file(outfile, allow_overwrite=True)
99+
outputter.output_to_file(outfile, allow_overwrite=True, indent=4)
105100

106101
return True

features/report-sbom.feature

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Feature: Create an CycloneDX sbom
88
The generated SBOM can be used as input for other tools to monitor dependencies.
99
The tools track vulnerabilities or can enforce a license policy within an organization.
1010

11-
Scenario: An fetched project generates an sbom
11+
Scenario: An fetched project generates a json sbom
1212
Given the manifest 'dfetch.yaml'
1313
"""
1414
manifest:
@@ -25,19 +25,19 @@ Feature: Create an CycloneDX sbom
2525
When I run "dfetch report -t sbom"
2626
Then the 'report.json' file contains
2727
"""
28-
{
29-
"$schema": "http://cyclonedx.org/schema/bom-1.4.schema.json",
28+
{
29+
"$schema": "http://cyclonedx.org/schema/bom-1.6.schema.json",
3030
"bomFormat": "CycloneDX",
31-
"specVersion": "1.4",
32-
"serialNumber": "urn:uuid:e989dc42-a199-4fe4-87f1-2b7f7a5f48cf",
31+
"specVersion": "1.6",
32+
"serialNumber": "urn:uuid:3ce78767-c202-4beb-935e-67f539cf3a58",
3333
"version": 1,
3434
"dependencies": [
3535
{
36-
"ref": "a3aff0d8-2f40-4482-bded-577466c0bde9"
36+
"ref": "BomRef.7805091949677974.3172811758515278"
3737
}
3838
],
3939
"metadata": {
40-
"timestamp": "2023-03-25T19:15:03.697694+00:00",
40+
"timestamp": "2025-10-03T20:56:03.645362+00:00",
4141
"tools": [
4242
{
4343
"vendor": "dfetch-org",
@@ -47,14 +47,14 @@ Feature: Create an CycloneDX sbom
4747
{
4848
"vendor": "CycloneDX",
4949
"name": "cyclonedx-python-lib",
50-
"version": "5.0.1",
50+
"version": "7.1.0",
5151
"externalReferences": [
5252
{
5353
"url": "https://pypi.org/project/cyclonedx-python-lib/",
5454
"type": "distribution"
5555
},
5656
{
57-
"url": "https://cyclonedx.org",
57+
"url": "https://github.com/CycloneDX/cyclonedx-python-lib/#readme",
5858
"type": "website"
5959
},
6060
{
@@ -70,7 +70,7 @@ Feature: Create an CycloneDX sbom
7070
"type": "release-notes"
7171
},
7272
{
73-
"url": "https://cyclonedx.github.io/cyclonedx-python-lib/",
73+
"url": "https://cyclonedx-python-library.readthedocs.io/",
7474
"type": "documentation"
7575
},
7676
{
@@ -88,7 +88,7 @@ Feature: Create an CycloneDX sbom
8888
"components": [
8989
{
9090
"type": "library",
91-
"bom-ref": "a3aff0d8-2f40-4482-bded-577466c0bde9",
91+
"bom-ref": "BomRef.7805091949677974.3172811758515278",
9292
"name": "cpputest",
9393
"version": "v3.4",
9494
"externalReferences": [

features/steps/generic_steps.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
git_hash = re.compile(r"(\s?)[a-f0-9]{40}(\s?)")
2424
iso_timestamp = re.compile(r'"\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.\d{6}\+\d{2}:\d{2}')
2525
urn_uuid = re.compile(r"[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}")
26+
bom_ref = re.compile(r"BomRef.[0-9]{16}\.[0-9]{16}")
2627
svn_error = re.compile(r"svn: E\d{6}: .+")
2728

2829

@@ -101,6 +102,7 @@ def check_content(
101102
(git_hash, r"\1[commit hash]\2"),
102103
(iso_timestamp, "[timestamp]"),
103104
(urn_uuid, "[urn-uuid]"),
105+
(bom_ref, "[bom-ref]"),
104106
],
105107
text=expected,
106108
)
@@ -110,6 +112,7 @@ def check_content(
110112
(git_hash, r"\1[commit hash]\2"),
111113
(iso_timestamp, "[timestamp]"),
112114
(urn_uuid, "[urn-uuid]"),
115+
(bom_ref, "[bom-ref]"),
113116
],
114117
text=actual,
115118
)

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ dependencies = [
4848
"sarif-om==1.0.4",
4949
"semver==3.0.4",
5050
"patch-ng==1.18.1",
51-
"cyclonedx-python-lib==5.0.1",
51+
"cyclonedx-python-lib==7.1.0",
5252
"infer-license==0.1.0; python_version <= '3.10.0'",
5353
"infer-license==0.2.0; python_version > '3.10.0'",
5454
'setuptools; python_version >= "3.12"', # contains 'pkg_resources' for infer-license

0 commit comments

Comments
 (0)