Skip to content

Commit 7a6e637

Browse files
committed
feat: add support for CycloneDX 1.7 (basic)
Signed-off-by: Jan Kowalleck <jan.kowalleck@gmail.com>
1 parent fa3ac40 commit 7a6e637

File tree

12 files changed

+19
-27
lines changed

12 files changed

+19
-27
lines changed

cyclonedx/model/license.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,7 @@
3333
from .._internal.compare import ComparableTuple as _ComparableTuple
3434
from ..exception.model import MutuallyExclusivePropertiesException
3535
from ..exception.serialization import CycloneDxDeserializationException
36-
from ..schema.schema import (
37-
SchemaVersion1Dot5,
38-
SchemaVersion1Dot6,
39-
SchemaVersion1Dot7,
40-
)
36+
from ..schema.schema import SchemaVersion1Dot5, SchemaVersion1Dot6, SchemaVersion1Dot7
4137
from . import AttachedText, XsUri
4238
from .bom_ref import BomRef
4339

cyclonedx/model/tool.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,7 @@
2828

2929
from .._internal.compare import ComparableTuple as _ComparableTuple
3030
from ..schema import SchemaVersion
31-
from ..schema.schema import (
32-
SchemaVersion1Dot4,
33-
SchemaVersion1Dot5,
34-
SchemaVersion1Dot6,
35-
SchemaVersion1Dot7,
36-
)
31+
from ..schema.schema import SchemaVersion1Dot4, SchemaVersion1Dot5, SchemaVersion1Dot6, SchemaVersion1Dot7
3732
from . import ExternalReference, HashType, _HashTypeRepositorySerializationHelper
3833
from .component import Component
3934
from .service import Service

cyclonedx/model/vulnerability.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,7 @@
4242
from .._internal.bom_ref import bom_ref_from_str as _bom_ref_from_str
4343
from .._internal.compare import ComparableTuple as _ComparableTuple
4444
from ..exception.model import MutuallyExclusivePropertiesException, NoPropertiesProvidedException
45-
from ..schema.schema import (
46-
SchemaVersion1Dot4,
47-
SchemaVersion1Dot5,
48-
SchemaVersion1Dot6,
49-
SchemaVersion1Dot7,
50-
)
45+
from ..schema.schema import SchemaVersion1Dot4, SchemaVersion1Dot5, SchemaVersion1Dot6, SchemaVersion1Dot7
5146
from . import Property, XsUri
5247
from .bom_ref import BomRef
5348
from .contact import OrganizationalContact, OrganizationalEntity

cyclonedx/output/json.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ class JsonV1Dot6(Json, SchemaVersion1Dot6):
131131
def _get_schema_uri(self) -> str:
132132
return 'http://cyclonedx.org/schema/bom-1.6.schema.json'
133133

134+
134135
class JsonV1Dot7(Json, SchemaVersion1Dot7):
135136

136137
def _get_schema_uri(self) -> str:

cyclonedx/output/xml.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ class XmlV1Dot5(Xml, SchemaVersion1Dot5):
124124
class XmlV1Dot6(Xml, SchemaVersion1Dot6):
125125
pass
126126

127+
127128
class XmlV1Dot7(Xml, SchemaVersion1Dot7):
128129
pass
129130

cyclonedx/schema/schema.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ class SchemaVersion1Dot7(BaseSchemaVersion):
4040
def schema_version_enum(self) -> Literal[SchemaVersion.V1_7]:
4141
return SchemaVersion.V1_7
4242

43+
4344
class SchemaVersion1Dot6(BaseSchemaVersion):
4445

4546
@property

docs/outputting.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,16 +46,16 @@ as a ``str``.
4646
4747
from cyclonedx.output import make_outputter, BaseOutput, OutputFormat, SchemaVersion
4848
49-
outputter: BaseOutput = make_outputter(bom=bom, output_format=OutputFormat.JSON, schema_version=SchemaVersion.V1_6)
49+
outputter: BaseOutput = make_outputter(bom=bom, output_format=OutputFormat.JSON, schema_version=SchemaVersion.V1_7)
5050
bom_json: str = outputter.output_as_string()
5151
5252
Alternatively, if the output format and schema version are constants, you can use the predefined format+schema combined outputs:
5353

5454
.. code-block:: python
5555
56-
from cyclonedx.output.json import JsonV1Dot6
56+
from cyclonedx.output.json import JsonV1Dot7
5757
58-
outputter = JsonV1Dot6(bom=bom)
58+
outputter = JsonV1Dot7(bom=bom)
5959
bom_json: str = outputter.output_as_string()
6060
6161

docs/responsibilities_capabilities.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ Capabilities
5353
* Build a :class:`Component <cyclonedx.model.component.Component>` data model that represents this library
5454
* Build a :class:`Tool <cyclonedx.model.tool.Tool>` data model that represents this library
5555
* Implementation of the `CycloneDX Specification`_ for the following versions:
56+
* ``1.7``
5657
* ``1.6``
5758
* ``1.5``
5859
* ``1.4``

examples/complex_deserialize.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@
3333
# region JSON
3434

3535
json_data = """{
36-
"$schema": "http://cyclonedx.org/schema/bom-1.6.schema.json",
36+
"$schema": "http://cyclonedx.org/schema/bom-1.7.schema.json",
3737
"bomFormat": "CycloneDX",
38-
"specVersion": "1.6",
38+
"specVersion": "1.7",
3939
"serialNumber": "urn:uuid:88fabcfa-7529-4ba2-8256-29bec0c03900",
4040
"version": 1,
4141
"metadata": {
@@ -145,7 +145,7 @@
145145
}
146146
]
147147
}"""
148-
my_json_validator = JsonStrictValidator(SchemaVersion.V1_6)
148+
my_json_validator = JsonStrictValidator(SchemaVersion.V1_7)
149149
try:
150150
json_validation_errors = my_json_validator.validate_str(json_data)
151151
if json_validation_errors:
@@ -165,7 +165,7 @@
165165
# endregion XML
166166

167167
xml_data = """<?xml version="1.0" ?>
168-
<bom xmlns="http://cyclonedx.org/schema/bom/1.6"
168+
<bom xmlns="http://cyclonedx.org/schema/bom/1.7"
169169
serialNumber="urn:uuid:88fabcfa-7529-4ba2-8256-29bec0c03900"
170170
version="1"
171171
>
@@ -246,7 +246,7 @@
246246
</dependency>
247247
</dependencies>
248248
</bom>"""
249-
my_xml_validator: 'XmlValidator' = make_schemabased_validator(OutputFormat.XML, SchemaVersion.V1_6)
249+
my_xml_validator: 'XmlValidator' = make_schemabased_validator(OutputFormat.XML, SchemaVersion.V1_7)
250250
try:
251251
xml_validation_errors = my_xml_validator.validate_str(xml_data)
252252
if xml_validation_errors:

examples/complex_serialize.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@
8989
my_json_outputter: 'JsonOutputter' = JsonV1Dot5(bom)
9090
serialized_json = my_json_outputter.output_as_string(indent=2)
9191
print(serialized_json)
92-
my_json_validator = JsonStrictValidator(SchemaVersion.V1_6)
92+
my_json_validator = JsonStrictValidator(SchemaVersion.V1_7)
9393
try:
9494
json_validation_errors = my_json_validator.validate_str(serialized_json)
9595
if json_validation_errors:
@@ -106,7 +106,7 @@
106106
# region XML
107107
"""demo with implicit instructions for SchemaVersion, outputter and validator. TypeCheckers will catch errors."""
108108

109-
my_xml_outputter: 'XmlOutputter' = make_outputter(bom, OutputFormat.XML, SchemaVersion.V1_6)
109+
my_xml_outputter: 'XmlOutputter' = make_outputter(bom, OutputFormat.XML, SchemaVersion.V1_7)
110110
serialized_xml = my_xml_outputter.output_as_string(indent=2)
111111
print(serialized_xml)
112112
my_xml_validator: 'XmlValidator' = make_schemabased_validator(

0 commit comments

Comments
 (0)