Skip to content

Commit fa3ac40

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

File tree

153 files changed

+25732
-127
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

153 files changed

+25732
-127
lines changed

cyclonedx/model/__init__.py

Lines changed: 31 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
SchemaVersion1Dot4,
4949
SchemaVersion1Dot5,
5050
SchemaVersion1Dot6,
51+
SchemaVersion1Dot7,
5152
)
5253
from .bom_ref import BomRef
5354

@@ -60,7 +61,7 @@ class DataFlow(str, Enum):
6061
This is our internal representation of the dataFlowType simple type within the CycloneDX standard.
6162
6263
.. note::
63-
See the CycloneDX Schema: https://cyclonedx.org/docs/1.6/xml/#type_dataFlowType
64+
See the CycloneDX Schema: https://cyclonedx.org/docs/1.7/xml/#type_dataFlowType
6465
"""
6566
INBOUND = 'inbound'
6667
OUTBOUND = 'outbound'
@@ -78,7 +79,7 @@ class DataClassification:
7879
7980
.. note::
8081
See the CycloneDX Schema for dataClassificationType:
81-
https://cyclonedx.org/docs/1.6/xml/#type_dataClassificationType
82+
https://cyclonedx.org/docs/1.7/xml/#type_dataClassificationType
8283
"""
8384

8485
def __init__(
@@ -157,7 +158,7 @@ class Encoding(str, Enum):
157158
This is our internal representation of the encoding simple type within the CycloneDX standard.
158159
159160
.. note::
160-
See the CycloneDX Schema: https://cyclonedx.org/docs/1.6/xml/#type_encoding
161+
See the CycloneDX Schema: https://cyclonedx.org/docs/1.7/xml/#type_encoding
161162
"""
162163
BASE_64 = 'base64'
163164

@@ -168,7 +169,7 @@ class AttachedText:
168169
This is our internal representation of the `attachedTextType` complex type within the CycloneDX standard.
169170
170171
.. note::
171-
See the CycloneDX Schema for hashType: https://cyclonedx.org/docs/1.6/xml/#type_attachedTextType
172+
See the CycloneDX Schema for hashType: https://cyclonedx.org/docs/1.7/xml/#type_attachedTextType
172173
"""
173174

174175
DEFAULT_CONTENT_TYPE = 'text/plain'
@@ -261,7 +262,7 @@ class HashAlgorithm(str, Enum):
261262
This is our internal representation of the hashAlg simple type within the CycloneDX standard.
262263
263264
.. note::
264-
See the CycloneDX Schema: https://cyclonedx.org/docs/1.6/xml/#type_hashAlg
265+
See the CycloneDX Schema: https://cyclonedx.org/docs/1.7/xml/#type_hashAlg
265266
"""
266267
# see `_HashTypeRepositorySerializationHelper.__CASES` for view/case map
267268
BLAKE2B_256 = 'BLAKE2b-256' # Only supported in >= 1.2
@@ -276,6 +277,8 @@ class HashAlgorithm(str, Enum):
276277
SHA3_256 = 'SHA3-256'
277278
SHA3_384 = 'SHA3-384' # Only supported in >= 1.2
278279
SHA3_512 = 'SHA3-512'
280+
STREEBOG_256 = 'Streebog-256'
281+
STREEBOG_512 = 'Streebog-512'
279282

280283

281284
class _HashTypeRepositorySerializationHelper(serializable.helpers.BaseHelper):
@@ -303,6 +306,10 @@ class _HashTypeRepositorySerializationHelper(serializable.helpers.BaseHelper):
303306
__CASES[SchemaVersion1Dot4] = __CASES[SchemaVersion1Dot3]
304307
__CASES[SchemaVersion1Dot5] = __CASES[SchemaVersion1Dot4]
305308
__CASES[SchemaVersion1Dot6] = __CASES[SchemaVersion1Dot5]
309+
__CASES[SchemaVersion1Dot7] = __CASES[SchemaVersion1Dot6] | {
310+
HashAlgorithm.STREEBOG_256,
311+
HashAlgorithm.STREEBOG_512,
312+
}
306313

307314
@classmethod
308315
def __prep(cls, hts: Iterable['HashType'], view: type[serializable.ViewType]) -> Generator['HashType', None, None]:
@@ -384,7 +391,7 @@ class HashType:
384391
This is our internal representation of the hashType complex type within the CycloneDX standard.
385392
386393
.. note::
387-
See the CycloneDX Schema for hashType: https://cyclonedx.org/docs/1.6/xml/#type_hashType
394+
See the CycloneDX Schema for hashType: https://cyclonedx.org/docs/1.7/xml/#type_hashType
388395
"""
389396

390397
@staticmethod
@@ -541,7 +548,7 @@ class ExternalReferenceType(str, Enum):
541548
Enum object that defines the permissible 'types' for an External Reference according to the CycloneDX schema.
542549
543550
.. note::
544-
See the CycloneDX Schema definition: https://cyclonedx.org/docs/1.6/xml/#type_externalReferenceType
551+
See the CycloneDX Schema definition: https://cyclonedx.org/docs/1.7/xml/#type_externalReferenceType
545552
"""
546553
# see `_ExternalReferenceSerializationHelper.__CASES` for view/case map
547554
ADVERSARY_MODEL = 'adversary-model' # Only supported in >= 1.5
@@ -587,6 +594,10 @@ class ExternalReferenceType(str, Enum):
587594
VCS = 'vcs'
588595
VULNERABILITY_ASSERTION = 'vulnerability-assertion' # Only supported in >= 1.5
589596
WEBSITE = 'website'
597+
CITATION = 'citation'
598+
PATENT = 'patent'
599+
PATENT_ASSERTION = 'patent-assertion'
600+
PATENT_FAMILY = 'patent-family'
590601
# --
591602
OTHER = 'other'
592603

@@ -648,6 +659,12 @@ class _ExternalReferenceSerializationHelper(serializable.helpers.BaseHelper):
648659
ExternalReferenceType.DIGITAL_SIGNATURE,
649660
ExternalReferenceType.RFC_9166,
650661
}
662+
__CASES[SchemaVersion1Dot7] = __CASES[SchemaVersion1Dot6] | {
663+
ExternalReferenceType.CITATION,
664+
ExternalReferenceType.PATENT,
665+
ExternalReferenceType.PATENT_ASSERTION,
666+
ExternalReferenceType.PATENT_FAMILY,
667+
}
651668

652669
@classmethod
653670
def __normalize(cls, extref: ExternalReferenceType, view: type[serializable.ViewType]) -> str:
@@ -809,7 +826,7 @@ class ExternalReference:
809826
a CycloneDX BOM document.
810827
811828
.. note::
812-
See the CycloneDX Schema definition: https://cyclonedx.org/docs/1.6/xml/#type_externalReference
829+
See the CycloneDX Schema definition: https://cyclonedx.org/docs/1.7/xml/#type_externalReference
813830
"""
814831

815832
def __init__(
@@ -877,6 +894,7 @@ def type(self, type: ExternalReferenceType) -> None:
877894
@serializable.view(SchemaVersion1Dot4)
878895
@serializable.view(SchemaVersion1Dot5)
879896
@serializable.view(SchemaVersion1Dot6)
897+
@serializable.view(SchemaVersion1Dot7)
880898
@serializable.type_mapping(_HashTypeRepositorySerializationHelper)
881899
def hashes(self) -> 'SortedSet[HashType]':
882900
"""
@@ -921,7 +939,7 @@ class Property:
921939
a CycloneDX BOM document.
922940
923941
.. note::
924-
See the CycloneDX Schema definition: https://cyclonedx.org/docs/1.6/xml/#type_propertyType
942+
See the CycloneDX Schema definition: https://cyclonedx.org/docs/1.7/xml/#type_propertyType
925943
926944
Specifies an individual property with a name and value.
927945
"""
@@ -996,7 +1014,7 @@ class NoteText:
9961014
a CycloneDX BOM document.
9971015
9981016
.. note::
999-
See the CycloneDX Schema definition: https://cyclonedx.org/docs/1.6/xml/#type_releaseNotesType
1017+
See the CycloneDX Schema definition: https://cyclonedx.org/docs/1.7/xml/#type_releaseNotesType
10001018
"""
10011019

10021020
DEFAULT_CONTENT_TYPE: str = 'text/plain'
@@ -1088,7 +1106,7 @@ class Note:
10881106
a CycloneDX BOM document.
10891107
10901108
.. note::
1091-
See the CycloneDX Schema definition: https://cyclonedx.org/docs/1.6/xml/#type_releaseNotesType
1109+
See the CycloneDX Schema definition: https://cyclonedx.org/docs/1.7/xml/#type_releaseNotesType
10921110
10931111
@todo: Replace ``NoteText`` with ``AttachedText``?
10941112
"""
@@ -1172,7 +1190,7 @@ class IdentifiableAction:
11721190
This is our internal representation of the `identifiableActionType` complex type.
11731191
11741192
.. note::
1175-
See the CycloneDX specification: https://cyclonedx.org/docs/1.6/xml/#type_identifiableActionType
1193+
See the CycloneDX specification: https://cyclonedx.org/docs/1.7/xml/#type_identifiableActionType
11761194
"""
11771195

11781196
def __init__(
@@ -1258,7 +1276,7 @@ class Copyright:
12581276
This is our internal representation of the `copyrightsType` complex type.
12591277
12601278
.. note::
1261-
See the CycloneDX specification: https://cyclonedx.org/docs/1.6/xml/#type_copyrightsType
1279+
See the CycloneDX specification: https://cyclonedx.org/docs/1.7/xml/#type_copyrightsType
12621280
"""
12631281

12641282
def __init__(

cyclonedx/model/bom.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
SchemaVersion1Dot4,
3838
SchemaVersion1Dot5,
3939
SchemaVersion1Dot6,
40+
SchemaVersion1Dot7,
4041
)
4142
from ..serialization import UrnUuidHelper
4243
from . import _BOM_LINK_PREFIX, ExternalReference, Property
@@ -61,7 +62,7 @@ class BomMetaData:
6162
This is our internal representation of the metadata complex type within the CycloneDX standard.
6263
6364
.. note::
64-
See the CycloneDX Schema for Bom metadata: https://cyclonedx.org/docs/1.6/xml/#type_metadata
65+
See the CycloneDX Schema for Bom metadata: https://cyclonedx.org/docs/1.7/xml/#type_metadata
6566
"""
6667

6768
def __init__(
@@ -109,6 +110,7 @@ def timestamp(self, timestamp: datetime) -> None:
109110
@property
110111
@serializable.view(SchemaVersion1Dot5)
111112
@serializable.view(SchemaVersion1Dot6)
113+
@serializable.view(SchemaVersion1Dot7)
112114
@serializable.type_mapping(_LifecycleRepositoryHelper)
113115
@serializable.xml_sequence(2)
114116
def lifecycles(self) -> LifecycleRepository:
@@ -193,6 +195,7 @@ def component(self, component: Optional[Component]) -> None:
193195
@serializable.view(SchemaVersion1Dot4)
194196
@serializable.view(SchemaVersion1Dot5)
195197
@serializable.view(SchemaVersion1Dot6)
198+
@serializable.view(SchemaVersion1Dot7)
196199
@serializable.xml_sequence(6)
197200
def manufacture(self) -> Optional[OrganizationalEntity]:
198201
"""
@@ -218,6 +221,7 @@ def manufacture(self, manufacture: Optional[OrganizationalEntity]) -> None:
218221

219222
@property
220223
@serializable.view(SchemaVersion1Dot6)
224+
@serializable.view(SchemaVersion1Dot7)
221225
@serializable.xml_sequence(7)
222226
def manufacturer(self) -> Optional[OrganizationalEntity]:
223227
"""
@@ -256,6 +260,7 @@ def supplier(self, supplier: Optional[OrganizationalEntity]) -> None:
256260
@serializable.view(SchemaVersion1Dot4)
257261
@serializable.view(SchemaVersion1Dot5)
258262
@serializable.view(SchemaVersion1Dot6)
263+
@serializable.view(SchemaVersion1Dot7)
259264
@serializable.type_mapping(_LicenseRepositorySerializationHelper)
260265
@serializable.xml_sequence(9)
261266
def licenses(self) -> LicenseRepository:
@@ -276,6 +281,7 @@ def licenses(self, licenses: Iterable[License]) -> None:
276281
@serializable.view(SchemaVersion1Dot4)
277282
@serializable.view(SchemaVersion1Dot5)
278283
@serializable.view(SchemaVersion1Dot6)
284+
@serializable.view(SchemaVersion1Dot7)
279285
@serializable.xml_array(serializable.XmlArraySerializationType.NESTED, 'property')
280286
@serializable.xml_sequence(10)
281287
def properties(self) -> 'SortedSet[Property]':
@@ -371,6 +377,7 @@ def __init__(
371377
@serializable.view(SchemaVersion1Dot4)
372378
@serializable.view(SchemaVersion1Dot5)
373379
@serializable.view(SchemaVersion1Dot6)
380+
@serializable.view(SchemaVersion1Dot7)
374381
@serializable.xml_attribute()
375382
def serial_number(self) -> UUID:
376383
"""
@@ -401,6 +408,7 @@ def version(self, version: int) -> None:
401408
@serializable.view(SchemaVersion1Dot4)
402409
@serializable.view(SchemaVersion1Dot5)
403410
@serializable.view(SchemaVersion1Dot6)
411+
@serializable.view(SchemaVersion1Dot7)
404412
@serializable.xml_sequence(10)
405413
def metadata(self) -> BomMetaData:
406414
"""
@@ -410,7 +418,7 @@ def metadata(self) -> BomMetaData:
410418
Metadata object instance for this Bom.
411419
412420
.. note::
413-
See the CycloneDX Schema for Bom metadata: https://cyclonedx.org/docs/1.6/xml/#type_metadata
421+
See the CycloneDX Schema for Bom metadata: https://cyclonedx.org/docs/1.7/xml/#type_metadata
414422
"""
415423
return self._metadata
416424

@@ -442,6 +450,7 @@ def components(self, components: Iterable[Component]) -> None:
442450
@serializable.view(SchemaVersion1Dot4)
443451
@serializable.view(SchemaVersion1Dot5)
444452
@serializable.view(SchemaVersion1Dot6)
453+
@serializable.view(SchemaVersion1Dot7)
445454
@serializable.xml_array(serializable.XmlArraySerializationType.NESTED, 'service')
446455
@serializable.xml_sequence(30)
447456
def services(self) -> 'SortedSet[Service]':
@@ -464,6 +473,7 @@ def services(self, services: Iterable[Service]) -> None:
464473
@serializable.view(SchemaVersion1Dot4)
465474
@serializable.view(SchemaVersion1Dot5)
466475
@serializable.view(SchemaVersion1Dot6)
476+
@serializable.view(SchemaVersion1Dot7)
467477
@serializable.xml_array(serializable.XmlArraySerializationType.NESTED, 'reference')
468478
@serializable.xml_sequence(40)
469479
def external_references(self) -> 'SortedSet[ExternalReference]':
@@ -485,6 +495,7 @@ def external_references(self, external_references: Iterable[ExternalReference])
485495
@serializable.view(SchemaVersion1Dot4)
486496
@serializable.view(SchemaVersion1Dot5)
487497
@serializable.view(SchemaVersion1Dot6)
498+
@serializable.view(SchemaVersion1Dot7)
488499
@serializable.xml_array(serializable.XmlArraySerializationType.NESTED, 'dependency')
489500
@serializable.xml_sequence(50)
490501
def dependencies(self) -> 'SortedSet[Dependency]':
@@ -512,6 +523,7 @@ def dependencies(self, dependencies: Iterable[Dependency]) -> None:
512523
# @serializable.view(SchemaVersion1Dot4) @todo: Update py-serializable to support view by OutputFormat filtering
513524
@serializable.view(SchemaVersion1Dot5)
514525
@serializable.view(SchemaVersion1Dot6)
526+
@serializable.view(SchemaVersion1Dot7)
515527
@serializable.xml_array(serializable.XmlArraySerializationType.NESTED, 'property')
516528
@serializable.xml_sequence(70)
517529
def properties(self) -> 'SortedSet[Property]':
@@ -534,6 +546,7 @@ def properties(self, properties: Iterable[Property]) -> None:
534546
@serializable.view(SchemaVersion1Dot4)
535547
@serializable.view(SchemaVersion1Dot5)
536548
@serializable.view(SchemaVersion1Dot6)
549+
@serializable.view(SchemaVersion1Dot7)
537550
@serializable.xml_array(serializable.XmlArraySerializationType.NESTED, 'vulnerability')
538551
@serializable.xml_sequence(80)
539552
def vulnerabilities(self) -> 'SortedSet[Vulnerability]':
@@ -573,6 +586,7 @@ def vulnerabilities(self, vulnerabilities: Iterable[Vulnerability]) -> None:
573586

574587
@property
575588
@serializable.view(SchemaVersion1Dot6)
589+
@serializable.view(SchemaVersion1Dot7)
576590
@serializable.xml_sequence(110)
577591
def definitions(self) -> Optional[Definitions]:
578592
"""

0 commit comments

Comments
 (0)