Skip to content

Commit 313a6fe

Browse files
Churrojkowalleck
andauthored
feat: add basic support for CDX 1.5 (#488)
This PR introduces basic support for CDX 1.5. Ref: - #404 **Schema:** - Extended schema-downloader and added specification files, - Adapted `README` and `SchemaVersion` for 1.5 **Model:** - Added `SchemaVersion1Dot5`, serializable annotations, - Extended `ComponentType` and `ExternalReferenceType` enums **Tests:** - Generated snapshots for 1.5. - In some existing tests `bom-ref` changed, since 1.5 is now listed before 1.4 **Chore:** - Added `newline = '\n'` to schema-downloader and `writeSnapshot` for cross-platform support ---- * feat: add basic support for CDX 1.5 Signed-off-by: Johannes Feichtner <[email protected]> * docs: note minversions of `HashAlgorithm` cases Signed-off-by: Jan Kowalleck <[email protected]> * docs: set ref after schema download Signed-off-by: Jan Kowalleck <[email protected]> * refactor: add the newly missing/TODO elements Signed-off-by: Jan Kowalleck <[email protected]> * docs: note minversions of `ComponentType` cases Signed-off-by: Jan Kowalleck <[email protected]> * refactor: adjust xml child order for CDX1.5 Signed-off-by: Jan Kowalleck <[email protected]> * refactor: adjust xml child order for CDX1.5 Signed-off-by: Jan Kowalleck <[email protected]> * docs: update to latest CDX meta Signed-off-by: Jan Kowalleck <[email protected]> * refactor: adjust xml child order for CDX1.5 Signed-off-by: Jan Kowalleck <[email protected]> * feat: new enum cases fr VulnerabilityScoreSource Signed-off-by: Jan Kowalleck <[email protected]> * refactor: adjust xml child order for CDX1.5 Signed-off-by: Jan Kowalleck <[email protected]> * tests: adjust to latest implementation Signed-off-by: Jan Kowalleck <[email protected]> * revert deletion by accident Signed-off-by: Jan Kowalleck <[email protected]> --------- Signed-off-by: Johannes Feichtner <[email protected]> Signed-off-by: Jan Kowalleck <[email protected]> Co-authored-by: Jan Kowalleck <[email protected]>
1 parent 78957e6 commit 313a6fe

File tree

66 files changed

+14624
-150
lines changed

Some content is hidden

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

66 files changed

+14624
-150
lines changed

README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
----
1515

1616
This Python package can render and read valid [CycloneDX][link_website] documents.
17-
CycloneDX is a lightweight BOM specification that is easily created, human-readable, and simple to parse.
17+
OWASP CycloneDX is a full-stack Bill of Materials (BOM) standard
18+
that provides advanced supply chain capabilities for cyber risk reduction.
1819

1920
**This module is not designed for standalone use.**
2021

cyclonedx/model/__init__.py

+38-7
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
NoPropertiesProvidedException,
3131
UnknownHashTypeException,
3232
)
33-
from ..schema.schema import SchemaVersion1Dot3, SchemaVersion1Dot4
33+
from ..schema.schema import SchemaVersion1Dot3, SchemaVersion1Dot4, SchemaVersion1Dot5
3434

3535
"""
3636
Uniform set of models to represent objects within a CycloneDX software bill-of-materials.
@@ -113,6 +113,9 @@ class DataClassification:
113113
"""
114114
This is our internal representation of the `dataClassificationType` complex type within the CycloneDX standard.
115115
116+
DataClassification might be deprecated since CycloneDX 1.5, but it is not deprecated in this library.
117+
In fact, this library will try to provide a compatibility layer if needed.
118+
116119
.. note::
117120
See the CycloneDX Schema for dataClassificationType:
118121
https://cyclonedx.org/docs/1.4/xml/#type_dataClassificationType
@@ -275,17 +278,17 @@ class HashAlgorithm(str, Enum):
275278
See the CycloneDX Schema: https://cyclonedx.org/docs/1.3/#type_hashAlg
276279
"""
277280

278-
BLAKE2B_256 = 'BLAKE2b-256'
279-
BLAKE2B_384 = 'BLAKE2b-384'
280-
BLAKE2B_512 = 'BLAKE2b-512'
281-
BLAKE3 = 'BLAKE3'
281+
BLAKE2B_256 = 'BLAKE2b-256' # Only supported in >= 1.2
282+
BLAKE2B_384 = 'BLAKE2b-384' # Only supported in >= 1.2
283+
BLAKE2B_512 = 'BLAKE2b-512' # Only supported in >= 1.2
284+
BLAKE3 = 'BLAKE3' # Only supported in >= 1.2
282285
MD5 = 'MD5'
283286
SHA_1 = 'SHA-1'
284287
SHA_256 = 'SHA-256'
285288
SHA_384 = 'SHA-384'
286289
SHA_512 = 'SHA-512'
287290
SHA3_256 = 'SHA3-256'
288-
SHA3_384 = 'SHA3-384'
291+
SHA3_384 = 'SHA3-384' # Only supported in >= 1.2
289292
SHA3_512 = 'SHA3-512'
290293

291294

@@ -395,22 +398,45 @@ class ExternalReferenceType(str, Enum):
395398
See the CycloneDX Schema definition: https://cyclonedx.org/docs/1.3/#type_externalReferenceType
396399
"""
397400

401+
ADVERSARY_MODEL = 'adversary-model' # Only supported in >= 1.5
398402
ADVISORIES = 'advisories'
403+
ATTESTATION = 'attestation' # Only supported in >= 1.5
399404
BOM = 'bom'
400405
BUILD_META = 'build-meta'
401406
BUILD_SYSTEM = 'build-system'
407+
CERTIFICATION_REPORT = 'certification-report' # Only supported in >= 1.5
402408
CHAT = 'chat'
409+
CODIFIED_INFRASTRUCTURE = 'codified-infrastructure' # Only supported in >= 1.5
410+
COMPONENT_ANALYSIS_REPORT = 'component-analysis-report' # Only supported in >= 1.5
411+
CONFIGURATION = 'configuration' # Only supported in >= 1.5
403412
DISTRIBUTION = 'distribution'
413+
DISTRIBUTION_INTAKE = 'distribution-intake' # Only supported in >= 1.5
404414
DOCUMENTATION = 'documentation'
415+
DYNAMIC_ANALYSIS_REPORT = 'dynamic-analysis-report' # Only supported in >= 1.5
416+
EVIDENCE = 'evidence' # Only supported in >= 1.5
417+
EXPLOITABILITY_STATEMENT = 'exploitability-statement' # Only supported in >= 1.5
418+
FORMULATION = 'formulation' # Only supported in >= 1.5
405419
ISSUE_TRACKER = 'issue-tracker'
406420
LICENSE = 'license'
421+
LOG = 'log' # Only supported in >= 1.5
407422
MAILING_LIST = 'mailing-list'
423+
MATURITY_REPORT = 'maturity-report' # Only supported in >= 1.5
424+
MODEL_CARD = 'model-card' # Only supported in >= 1.5
408425
OTHER = 'other'
426+
PENTEST_REPORT = 'pentest-report' # Only supported in >= 1.5
427+
POAM = 'poam' # Only supported in >= 1.5
428+
QUALITY_METRICS = 'quality-metrics' # Only supported in >= 1.5
409429
RELEASE_NOTES = 'release-notes' # Only supported in >= 1.4
430+
RISK_ASSESSMENT = 'risk-assessment' # Only supported in >= 1.5
431+
RUNTIME_ANALYSIS_REPORT = 'runtime-analysis-report' # Only supported in >= 1.5
432+
SECURITY_CONTACT = 'security-contact' # Only supported in >= 1.5
433+
STATIC_ANALYSIS_REPORT = 'static-analysis-report' # Only supported in >= 1.5
410434
SOCIAL = 'social'
411435
SCM = 'vcs'
412436
SUPPORT = 'support'
437+
THREAT_MODEL = 'threat-model' # Only supported in >= 1.5
413438
VCS = 'vcs'
439+
VULNERABILITY_ASSERTION = 'vulnerability-assertion' # Only supported in >= 1.5
414440
WEBSITE = 'website'
415441

416442

@@ -541,6 +567,7 @@ def type(self, type: ExternalReferenceType) -> None:
541567
@property
542568
@serializable.view(SchemaVersion1Dot3)
543569
@serializable.view(SchemaVersion1Dot4)
570+
@serializable.view(SchemaVersion1Dot5)
544571
@serializable.xml_array(serializable.XmlArraySerializationType.NESTED, 'hash')
545572
def hashes(self) -> 'SortedSet[HashType]':
546573
"""
@@ -974,7 +1001,10 @@ class Tool:
9741001
"""
9751002
This is our internal representation of the `toolType` complex type within the CycloneDX standard.
9761003
977-
Tool(s) are the things used in the creation of the BOM.
1004+
Tool(s) are the things used in the creation of the CycloneDX document.
1005+
1006+
Tool might be deprecated since CycloneDX 1.5, but it is not deprecated i this library.
1007+
In fact, this library will try to provide a compatibility layer if needed.
9781008
9791009
.. note::
9801010
See the CycloneDX Schema for toolType: https://cyclonedx.org/docs/1.3/#type_toolType
@@ -1052,6 +1082,7 @@ def hashes(self, hashes: Iterable[HashType]) -> None:
10521082

10531083
@property
10541084
@serializable.view(SchemaVersion1Dot4)
1085+
@serializable.view(SchemaVersion1Dot5)
10551086
@serializable.xml_array(serializable.XmlArraySerializationType.NESTED, 'reference')
10561087
@serializable.xml_sequence(5)
10571088
def external_references(self) -> 'SortedSet[ExternalReference]':

0 commit comments

Comments
 (0)