From 500f3cf46ffcb730c3b04a0ac5a4cb8f8291559b Mon Sep 17 00:00:00 2001 From: Jan Kowalleck Date: Mon, 8 Jun 2026 11:27:38 +0200 Subject: [PATCH 01/19] tests: test all the enums. Signed-off-by: Jan Kowalleck --- tests/test_enums.py | 59 ++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 56 insertions(+), 3 deletions(-) diff --git a/tests/test_enums.py b/tests/test_enums.py index 1d749d637..2af4efdd6 100644 --- a/tests/test_enums.py +++ b/tests/test_enums.py @@ -14,13 +14,14 @@ # # SPDX-License-Identifier: Apache-2.0 # Copyright (c) OWASP Foundation. All Rights Reserved. - - +import ast +from os import path +from glob import glob from collections.abc import Generator, Iterable from enum import Enum from itertools import chain from json import load as json_load -from typing import Any +from typing import Any, Optional from unittest import TestCase from warnings import warn from xml.etree.ElementTree import parse as xml_parse # nosec B405 @@ -508,3 +509,55 @@ def test_cases_render_valid(self, of: OutputFormat, sv: SchemaVersion, *_: Any, distribution_constraints=DistributionConstraints(tlp=TlpClassification.CLEAR) )) super()._test_cases_render(bom, of, sv) + + +# add new test cases above this line + +@ddt +class TestCaseCompleteness(TestCase): + """ + Test that all defined enum models are covered by a test case in here. + """ + + __TestCasePrefix = 'TestEnum' + + __defined_enumcases: Optional[tuple[str, ...]] = None + + @classmethod + def __get_defined_enumcases(cls) -> tuple[str, ...]: + if cls.__defined_enumcases is None: + cls.__defined_enumcases = tuple( + name for name, obj + in globals().items() + if isinstance(obj, type) + and obj.__module__ + and obj.__module__ == __name__ + and issubclass(obj, _EnumTestCase) + and not obj is _EnumTestCase + ) + return cls.__defined_enumcases + + @staticmethod + def __get_defined_model_enums(): + models_path = path.join(path.dirname(__file__), '..', 'cyclonedx', 'model') + model_files = glob(path.join('**', '*.py'), root_dir=models_path, recursive=True) + for model_file in model_files: + with open(path.join(models_path, model_file), 'r', encoding='utf-8') as f: + tree = ast.parse(f.read(), filename=model_file) + for node in ast.walk(tree): + if isinstance(node, ast.ClassDef): + for base in node.bases: + # Case 1: direct name: "Enum" + if isinstance(base, ast.Name) and base.id == 'Enum': + yield node.name + break + # Case 2: qualified name: "enum.Enum" + if isinstance(base, ast.Attribute) and base.attr == 'Enum': + yield node.name + break + + @idata(__get_defined_model_enums()) + def test_case_exists(self, enum_name) -> None: + self.assertIn(f'{self.__TestCasePrefix}{enum_name}', + self.__get_defined_enumcases(), + f'Missing Test Case for Enum: {enum_name}') From 06f34c5232a86ace204ce6e8a67b2413e98838a3 Mon Sep 17 00:00:00 2001 From: Jan Kowalleck Date: Mon, 8 Jun 2026 11:30:40 +0200 Subject: [PATCH 02/19] tests: test all the enums. Signed-off-by: Jan Kowalleck --- tests/test_enums.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tests/test_enums.py b/tests/test_enums.py index 2af4efdd6..53006f4d4 100644 --- a/tests/test_enums.py +++ b/tests/test_enums.py @@ -510,6 +510,23 @@ def test_cases_render_valid(self, of: OutputFormat, sv: SchemaVersion, *_: Any, )) super()._test_cases_render(bom, of, sv) +""" +missing: +- LicenseAcknowledgement +- CryptoAssetType +- CryptoPrimitive +- CryptoExecutionEnvironment +- CryptoImplementationPlatform +- CryptoCertificationLevel +- CryptoMode +- CryptoPadding +- CryptoFunction +- RelatedCryptoMaterialType +- RelatedCryptoMaterialState +- ProtocolPropertiesType +- IdentityField +- AnalysisTechnique +""" # add new test cases above this line From 5efa4609c38efdc8be2325e49eb654006b0a2336 Mon Sep 17 00:00:00 2001 From: Jan Kowalleck Date: Mon, 8 Jun 2026 12:40:16 +0200 Subject: [PATCH 03/19] tests: LicenseAcknowledgement Signed-off-by: Jan Kowalleck --- tests/__init__.py | 2 +- .../enum_LicenseAcknowledgement-1.0.xml.bin | 10 ++++ .../enum_LicenseAcknowledgement-1.1.xml.bin | 17 +++++++ .../enum_LicenseAcknowledgement-1.2.json.bin | 35 ++++++++++++++ .../enum_LicenseAcknowledgement-1.2.xml.bin | 23 ++++++++++ .../enum_LicenseAcknowledgement-1.3.json.bin | 35 ++++++++++++++ .../enum_LicenseAcknowledgement-1.3.xml.bin | 23 ++++++++++ .../enum_LicenseAcknowledgement-1.4.json.bin | 34 ++++++++++++++ .../enum_LicenseAcknowledgement-1.4.xml.bin | 22 +++++++++ .../enum_LicenseAcknowledgement-1.5.json.bin | 44 ++++++++++++++++++ .../enum_LicenseAcknowledgement-1.5.xml.bin | 26 +++++++++++ .../enum_LicenseAcknowledgement-1.6.json.bin | 46 +++++++++++++++++++ .../enum_LicenseAcknowledgement-1.6.xml.bin | 26 +++++++++++ .../enum_LicenseAcknowledgement-1.7.json.bin | 46 +++++++++++++++++++ .../enum_LicenseAcknowledgement-1.7.xml.bin | 26 +++++++++++ tests/test_enums.py | 23 ++++++++++ 16 files changed, 437 insertions(+), 1 deletion(-) create mode 100644 tests/_data/snapshots/enum_LicenseAcknowledgement-1.0.xml.bin create mode 100644 tests/_data/snapshots/enum_LicenseAcknowledgement-1.1.xml.bin create mode 100644 tests/_data/snapshots/enum_LicenseAcknowledgement-1.2.json.bin create mode 100644 tests/_data/snapshots/enum_LicenseAcknowledgement-1.2.xml.bin create mode 100644 tests/_data/snapshots/enum_LicenseAcknowledgement-1.3.json.bin create mode 100644 tests/_data/snapshots/enum_LicenseAcknowledgement-1.3.xml.bin create mode 100644 tests/_data/snapshots/enum_LicenseAcknowledgement-1.4.json.bin create mode 100644 tests/_data/snapshots/enum_LicenseAcknowledgement-1.4.xml.bin create mode 100644 tests/_data/snapshots/enum_LicenseAcknowledgement-1.5.json.bin create mode 100644 tests/_data/snapshots/enum_LicenseAcknowledgement-1.5.xml.bin create mode 100644 tests/_data/snapshots/enum_LicenseAcknowledgement-1.6.json.bin create mode 100644 tests/_data/snapshots/enum_LicenseAcknowledgement-1.6.xml.bin create mode 100644 tests/_data/snapshots/enum_LicenseAcknowledgement-1.7.json.bin create mode 100644 tests/_data/snapshots/enum_LicenseAcknowledgement-1.7.xml.bin diff --git a/tests/__init__.py b/tests/__init__.py index 772ffcdd7..585b8649f 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -40,7 +40,7 @@ OWN_DATA_DIRECTORY = path.join(_TESTDATA_DIRECTORY, 'own') SNAPSHOTS_DIRECTORY = path.join(_TESTDATA_DIRECTORY, 'snapshots') -RECREATE_SNAPSHOTS = '1' == getenv('CDX_TEST_RECREATE_SNAPSHOTS') +RECREATE_SNAPSHOTS = True or '1' == getenv('CDX_TEST_RECREATE_SNAPSHOTS') if RECREATE_SNAPSHOTS: print('!!! WILL RECREATE ALL SNAPSHOTS !!!') diff --git a/tests/_data/snapshots/enum_LicenseAcknowledgement-1.0.xml.bin b/tests/_data/snapshots/enum_LicenseAcknowledgement-1.0.xml.bin new file mode 100644 index 000000000..068b881e8 --- /dev/null +++ b/tests/_data/snapshots/enum_LicenseAcknowledgement-1.0.xml.bin @@ -0,0 +1,10 @@ + + + + + dummy + + false + + + diff --git a/tests/_data/snapshots/enum_LicenseAcknowledgement-1.1.xml.bin b/tests/_data/snapshots/enum_LicenseAcknowledgement-1.1.xml.bin new file mode 100644 index 000000000..286f4b440 --- /dev/null +++ b/tests/_data/snapshots/enum_LicenseAcknowledgement-1.1.xml.bin @@ -0,0 +1,17 @@ + + + + + dummy + + + + LicenseAcknowledgement: CONCLUDED + + + LicenseAcknowledgement: DECLARED + + + + + diff --git a/tests/_data/snapshots/enum_LicenseAcknowledgement-1.2.json.bin b/tests/_data/snapshots/enum_LicenseAcknowledgement-1.2.json.bin new file mode 100644 index 000000000..ad73237ba --- /dev/null +++ b/tests/_data/snapshots/enum_LicenseAcknowledgement-1.2.json.bin @@ -0,0 +1,35 @@ +{ + "components": [ + { + "bom-ref": "dummy", + "licenses": [ + { + "license": { + "name": "LicenseAcknowledgement: CONCLUDED" + } + }, + { + "license": { + "name": "LicenseAcknowledgement: DECLARED" + } + } + ], + "name": "dummy", + "type": "library", + "version": "" + } + ], + "dependencies": [ + { + "ref": "dummy" + } + ], + "metadata": { + "timestamp": "2023-01-07T13:44:32.312678+00:00" + }, + "serialNumber": "urn:uuid:1441d33a-e0fc-45b5-af3b-61ee52a88bac", + "version": 1, + "$schema": "http://cyclonedx.org/schema/bom-1.2b.schema.json", + "bomFormat": "CycloneDX", + "specVersion": "1.2" +} \ No newline at end of file diff --git a/tests/_data/snapshots/enum_LicenseAcknowledgement-1.2.xml.bin b/tests/_data/snapshots/enum_LicenseAcknowledgement-1.2.xml.bin new file mode 100644 index 000000000..a194bbc4e --- /dev/null +++ b/tests/_data/snapshots/enum_LicenseAcknowledgement-1.2.xml.bin @@ -0,0 +1,23 @@ + + + + 2023-01-07T13:44:32.312678+00:00 + + + + dummy + + + + LicenseAcknowledgement: CONCLUDED + + + LicenseAcknowledgement: DECLARED + + + + + + + + diff --git a/tests/_data/snapshots/enum_LicenseAcknowledgement-1.3.json.bin b/tests/_data/snapshots/enum_LicenseAcknowledgement-1.3.json.bin new file mode 100644 index 000000000..b10b2d7aa --- /dev/null +++ b/tests/_data/snapshots/enum_LicenseAcknowledgement-1.3.json.bin @@ -0,0 +1,35 @@ +{ + "components": [ + { + "bom-ref": "dummy", + "licenses": [ + { + "license": { + "name": "LicenseAcknowledgement: CONCLUDED" + } + }, + { + "license": { + "name": "LicenseAcknowledgement: DECLARED" + } + } + ], + "name": "dummy", + "type": "library", + "version": "" + } + ], + "dependencies": [ + { + "ref": "dummy" + } + ], + "metadata": { + "timestamp": "2023-01-07T13:44:32.312678+00:00" + }, + "serialNumber": "urn:uuid:1441d33a-e0fc-45b5-af3b-61ee52a88bac", + "version": 1, + "$schema": "http://cyclonedx.org/schema/bom-1.3a.schema.json", + "bomFormat": "CycloneDX", + "specVersion": "1.3" +} \ No newline at end of file diff --git a/tests/_data/snapshots/enum_LicenseAcknowledgement-1.3.xml.bin b/tests/_data/snapshots/enum_LicenseAcknowledgement-1.3.xml.bin new file mode 100644 index 000000000..5c050d8ad --- /dev/null +++ b/tests/_data/snapshots/enum_LicenseAcknowledgement-1.3.xml.bin @@ -0,0 +1,23 @@ + + + + 2023-01-07T13:44:32.312678+00:00 + + + + dummy + + + + LicenseAcknowledgement: CONCLUDED + + + LicenseAcknowledgement: DECLARED + + + + + + + + diff --git a/tests/_data/snapshots/enum_LicenseAcknowledgement-1.4.json.bin b/tests/_data/snapshots/enum_LicenseAcknowledgement-1.4.json.bin new file mode 100644 index 000000000..169eaebb5 --- /dev/null +++ b/tests/_data/snapshots/enum_LicenseAcknowledgement-1.4.json.bin @@ -0,0 +1,34 @@ +{ + "components": [ + { + "bom-ref": "dummy", + "licenses": [ + { + "license": { + "name": "LicenseAcknowledgement: CONCLUDED" + } + }, + { + "license": { + "name": "LicenseAcknowledgement: DECLARED" + } + } + ], + "name": "dummy", + "type": "library" + } + ], + "dependencies": [ + { + "ref": "dummy" + } + ], + "metadata": { + "timestamp": "2023-01-07T13:44:32.312678+00:00" + }, + "serialNumber": "urn:uuid:1441d33a-e0fc-45b5-af3b-61ee52a88bac", + "version": 1, + "$schema": "http://cyclonedx.org/schema/bom-1.4.schema.json", + "bomFormat": "CycloneDX", + "specVersion": "1.4" +} \ No newline at end of file diff --git a/tests/_data/snapshots/enum_LicenseAcknowledgement-1.4.xml.bin b/tests/_data/snapshots/enum_LicenseAcknowledgement-1.4.xml.bin new file mode 100644 index 000000000..41371698a --- /dev/null +++ b/tests/_data/snapshots/enum_LicenseAcknowledgement-1.4.xml.bin @@ -0,0 +1,22 @@ + + + + 2023-01-07T13:44:32.312678+00:00 + + + + dummy + + + LicenseAcknowledgement: CONCLUDED + + + LicenseAcknowledgement: DECLARED + + + + + + + + diff --git a/tests/_data/snapshots/enum_LicenseAcknowledgement-1.5.json.bin b/tests/_data/snapshots/enum_LicenseAcknowledgement-1.5.json.bin new file mode 100644 index 000000000..b0ff6171e --- /dev/null +++ b/tests/_data/snapshots/enum_LicenseAcknowledgement-1.5.json.bin @@ -0,0 +1,44 @@ +{ + "components": [ + { + "bom-ref": "dummy", + "licenses": [ + { + "license": { + "name": "LicenseAcknowledgement: CONCLUDED" + } + }, + { + "license": { + "name": "LicenseAcknowledgement: DECLARED" + } + } + ], + "name": "dummy", + "type": "library" + } + ], + "dependencies": [ + { + "ref": "dummy" + } + ], + "metadata": { + "timestamp": "2023-01-07T13:44:32.312678+00:00" + }, + "properties": [ + { + "name": "key1", + "value": "val1" + }, + { + "name": "key2", + "value": "val2" + } + ], + "serialNumber": "urn:uuid:1441d33a-e0fc-45b5-af3b-61ee52a88bac", + "version": 1, + "$schema": "http://cyclonedx.org/schema/bom-1.5.schema.json", + "bomFormat": "CycloneDX", + "specVersion": "1.5" +} \ No newline at end of file diff --git a/tests/_data/snapshots/enum_LicenseAcknowledgement-1.5.xml.bin b/tests/_data/snapshots/enum_LicenseAcknowledgement-1.5.xml.bin new file mode 100644 index 000000000..64bc51065 --- /dev/null +++ b/tests/_data/snapshots/enum_LicenseAcknowledgement-1.5.xml.bin @@ -0,0 +1,26 @@ + + + + 2023-01-07T13:44:32.312678+00:00 + + + + dummy + + + LicenseAcknowledgement: CONCLUDED + + + LicenseAcknowledgement: DECLARED + + + + + + + + + val1 + val2 + + diff --git a/tests/_data/snapshots/enum_LicenseAcknowledgement-1.6.json.bin b/tests/_data/snapshots/enum_LicenseAcknowledgement-1.6.json.bin new file mode 100644 index 000000000..3fa3c9274 --- /dev/null +++ b/tests/_data/snapshots/enum_LicenseAcknowledgement-1.6.json.bin @@ -0,0 +1,46 @@ +{ + "components": [ + { + "bom-ref": "dummy", + "licenses": [ + { + "license": { + "acknowledgement": "concluded", + "name": "LicenseAcknowledgement: CONCLUDED" + } + }, + { + "license": { + "acknowledgement": "declared", + "name": "LicenseAcknowledgement: DECLARED" + } + } + ], + "name": "dummy", + "type": "library" + } + ], + "dependencies": [ + { + "ref": "dummy" + } + ], + "metadata": { + "timestamp": "2023-01-07T13:44:32.312678+00:00" + }, + "properties": [ + { + "name": "key1", + "value": "val1" + }, + { + "name": "key2", + "value": "val2" + } + ], + "serialNumber": "urn:uuid:1441d33a-e0fc-45b5-af3b-61ee52a88bac", + "version": 1, + "$schema": "http://cyclonedx.org/schema/bom-1.6.schema.json", + "bomFormat": "CycloneDX", + "specVersion": "1.6" +} \ No newline at end of file diff --git a/tests/_data/snapshots/enum_LicenseAcknowledgement-1.6.xml.bin b/tests/_data/snapshots/enum_LicenseAcknowledgement-1.6.xml.bin new file mode 100644 index 000000000..7a92ab4f5 --- /dev/null +++ b/tests/_data/snapshots/enum_LicenseAcknowledgement-1.6.xml.bin @@ -0,0 +1,26 @@ + + + + 2023-01-07T13:44:32.312678+00:00 + + + + dummy + + + LicenseAcknowledgement: CONCLUDED + + + LicenseAcknowledgement: DECLARED + + + + + + + + + val1 + val2 + + diff --git a/tests/_data/snapshots/enum_LicenseAcknowledgement-1.7.json.bin b/tests/_data/snapshots/enum_LicenseAcknowledgement-1.7.json.bin new file mode 100644 index 000000000..2e9aee738 --- /dev/null +++ b/tests/_data/snapshots/enum_LicenseAcknowledgement-1.7.json.bin @@ -0,0 +1,46 @@ +{ + "components": [ + { + "bom-ref": "dummy", + "licenses": [ + { + "license": { + "acknowledgement": "concluded", + "name": "LicenseAcknowledgement: CONCLUDED" + } + }, + { + "license": { + "acknowledgement": "declared", + "name": "LicenseAcknowledgement: DECLARED" + } + } + ], + "name": "dummy", + "type": "library" + } + ], + "dependencies": [ + { + "ref": "dummy" + } + ], + "metadata": { + "timestamp": "2023-01-07T13:44:32.312678+00:00" + }, + "properties": [ + { + "name": "key1", + "value": "val1" + }, + { + "name": "key2", + "value": "val2" + } + ], + "serialNumber": "urn:uuid:1441d33a-e0fc-45b5-af3b-61ee52a88bac", + "version": 1, + "$schema": "http://cyclonedx.org/schema/bom-1.7.schema.json", + "bomFormat": "CycloneDX", + "specVersion": "1.7" +} \ No newline at end of file diff --git a/tests/_data/snapshots/enum_LicenseAcknowledgement-1.7.xml.bin b/tests/_data/snapshots/enum_LicenseAcknowledgement-1.7.xml.bin new file mode 100644 index 000000000..373ffa7ba --- /dev/null +++ b/tests/_data/snapshots/enum_LicenseAcknowledgement-1.7.xml.bin @@ -0,0 +1,26 @@ + + + + 2023-01-07T13:44:32.312678+00:00 + + + + dummy + + + LicenseAcknowledgement: CONCLUDED + + + LicenseAcknowledgement: DECLARED + + + + + + + + + val1 + val2 + + diff --git a/tests/test_enums.py b/tests/test_enums.py index 53006f4d4..ecb22244d 100644 --- a/tests/test_enums.py +++ b/tests/test_enums.py @@ -73,6 +73,9 @@ from cyclonedx.model.issue import ( # isort:skip IssueClassification, ) +from cyclonedx.model.license import ( # isort:skip + LicenseAcknowledgement +) from cyclonedx.model.vulnerability import ( # isort:skip VulnerabilityScoreSource, VulnerabilitySeverity, @@ -510,6 +513,26 @@ def test_cases_render_valid(self, of: OutputFormat, sv: SchemaVersion, *_: Any, )) super()._test_cases_render(bom, of, sv) + +@ddt +class TestEnumLicenseAcknowledgement(_EnumTestCase): + + @idata(set(chain( + dp_cases_from_xml_schemas(f"./{SCHEMA_NS}simpleType[@name='licenseAcknowledgementEnumerationType']"), + dp_cases_from_json_schemas('definitions', 'licenseAcknowledgementEnumeration'), + ))) + def test_knows_value(self, value: str) -> None: + super()._test_knows_value(LicenseAcknowledgement, value) + + @named_data(*NAMED_OF_SV) + def test_cases_render_valid(self, of: OutputFormat, sv: SchemaVersion, *_: Any, **__: Any) -> None: + bom = _make_bom(components=[Component(name='dummy', type=ComponentType.LIBRARY, bom_ref='dummy', licenses=( + DisjunctiveLicense(name=f'LicenseAcknowledgement: {la.name}', + acknowledgement=la, + ) for la in LicenseAcknowledgement + ))]) + super()._test_cases_render(bom, of, sv) + """ missing: - LicenseAcknowledgement From 8ddc37f66fe1632ec22e1366200234f25608aec4 Mon Sep 17 00:00:00 2001 From: Jan Kowalleck Date: Mon, 8 Jun 2026 12:57:15 +0200 Subject: [PATCH 04/19] isort Signed-off-by: Jan Kowalleck --- tests/test_enums.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/test_enums.py b/tests/test_enums.py index ecb22244d..e51eb87cc 100644 --- a/tests/test_enums.py +++ b/tests/test_enums.py @@ -14,13 +14,14 @@ # # SPDX-License-Identifier: Apache-2.0 # Copyright (c) OWASP Foundation. All Rights Reserved. + import ast -from os import path -from glob import glob from collections.abc import Generator, Iterable from enum import Enum +from glob import glob from itertools import chain from json import load as json_load +from os import path from typing import Any, Optional from unittest import TestCase from warnings import warn From 1dfe71fd21c1dbf4c991eb94505d357869afe0d5 Mon Sep 17 00:00:00 2001 From: Jan Kowalleck Date: Mon, 8 Jun 2026 12:57:50 +0200 Subject: [PATCH 05/19] autopep8 Signed-off-by: Jan Kowalleck --- tests/test_enums.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tests/test_enums.py b/tests/test_enums.py index e51eb87cc..85597f3f7 100644 --- a/tests/test_enums.py +++ b/tests/test_enums.py @@ -528,12 +528,13 @@ def test_knows_value(self, value: str) -> None: @named_data(*NAMED_OF_SV) def test_cases_render_valid(self, of: OutputFormat, sv: SchemaVersion, *_: Any, **__: Any) -> None: bom = _make_bom(components=[Component(name='dummy', type=ComponentType.LIBRARY, bom_ref='dummy', licenses=( - DisjunctiveLicense(name=f'LicenseAcknowledgement: {la.name}', - acknowledgement=la, - ) for la in LicenseAcknowledgement + DisjunctiveLicense(name=f'LicenseAcknowledgement: {la.name}', + acknowledgement=la, + ) for la in LicenseAcknowledgement ))]) super()._test_cases_render(bom, of, sv) + """ missing: - LicenseAcknowledgement @@ -554,6 +555,7 @@ def test_cases_render_valid(self, of: OutputFormat, sv: SchemaVersion, *_: Any, # add new test cases above this line + @ddt class TestCaseCompleteness(TestCase): """ From 20509fe56321d59897921009479fe13af30413b6 Mon Sep 17 00:00:00 2001 From: Jan Kowalleck Date: Mon, 8 Jun 2026 13:26:42 +0200 Subject: [PATCH 06/19] tests: TestEnumIdentityField & TestEnumAnalysisTechnique Signed-off-by: Jan Kowalleck --- tests/test_enums.py | 68 +++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 65 insertions(+), 3 deletions(-) diff --git a/tests/test_enums.py b/tests/test_enums.py index 85597f3f7..5025acca9 100644 --- a/tests/test_enums.py +++ b/tests/test_enums.py @@ -17,6 +17,7 @@ import ast from collections.abc import Generator, Iterable +from decimal import Decimal from enum import Enum from glob import glob from itertools import chain @@ -34,6 +35,7 @@ from cyclonedx.model import AttachedText, ExternalReference, HashType, XsUri from cyclonedx.model.bom import Bom, BomMetaData, DistributionConstraints, TlpClassification from cyclonedx.model.component import Component, Patch, Pedigree +from cyclonedx.model.component_evidence import ComponentEvidence, Identity as CEIdentity, Method as CEMethod from cyclonedx.model.issue import IssueType from cyclonedx.model.license import DisjunctiveLicense from cyclonedx.model.lifecycle import LifecyclePhase, PredefinedLifecycle @@ -65,6 +67,10 @@ ComponentType, PatchClassification, ) +from cyclonedx.model.component_evidence import ( # isort:skip + AnalysisTechnique, + IdentityField, +) from cyclonedx.model.impact_analysis import ( # isort:skip ImpactAnalysisAffectedStatus, ImpactAnalysisJustification, @@ -535,9 +541,67 @@ def test_cases_render_valid(self, of: OutputFormat, sv: SchemaVersion, *_: Any, super()._test_cases_render(bom, of, sv) + +@ddt +class TestEnumIdentityField(_EnumTestCase): + + @idata(set(chain( + dp_cases_from_xml_schemas(f"./{SCHEMA_NS}simpleType[@name='licenseAcknowledgementEnumerationType']"), + dp_cases_from_json_schemas('definitions', 'licenseAcknowledgementEnumeration'), + ))) + def test_knows_value(self, value: str) -> None: + super()._test_knows_value(LicenseAcknowledgement, value) + + @named_data(*NAMED_OF_SV) + def test_cases_render_valid(self, of: OutputFormat, sv: SchemaVersion, *_: Any, **__: Any) -> None: + bom = _make_bom(components=[ + Component( + name='dummy', type=ComponentType.LIBRARY, bom_ref='dummy', + evidence=ComponentEvidence(identity=[ + CEIdentity( + field=ce_if, + concluded_value=f'{ce_if.name}' + ) for ce_if in IdentityField + ])) + ]) + super()._test_cases_render(bom, of, sv) + + +@ddt +class TestEnumAnalysisTechnique(_EnumTestCase): + + @idata(set(chain( + dp_cases_from_xml_schemas(f"./{SCHEMA_NS}simpleType[@name='licenseAcknowledgementEnumerationType']"), + dp_cases_from_json_schemas('definitions', 'licenseAcknowledgementEnumeration'), + ))) + def test_knows_value(self, value: str) -> None: + super()._test_knows_value(LicenseAcknowledgement, value) + + @named_data(*NAMED_OF_SV) + def test_cases_render_valid(self, of: OutputFormat, sv: SchemaVersion, *_: Any, **__: Any) -> None: + bom = _make_bom( + components=[ + Component( + name='dummy', type=ComponentType.LIBRARY, bom_ref='dummy', + evidence=ComponentEvidence(identity=[ + CEIdentity( + field=IdentityField.NAME, + methods=[ + CEMethod( + confidence=Decimal(1.0), + value=f'AnalysisTechnique: {ce_at.name}', + technique=ce_at, + ) for ce_at in AnalysisTechnique + ]) + ]) + ) + ]) + super()._test_cases_render(bom, of, sv) + + + """ missing: -- LicenseAcknowledgement - CryptoAssetType - CryptoPrimitive - CryptoExecutionEnvironment @@ -549,8 +613,6 @@ def test_cases_render_valid(self, of: OutputFormat, sv: SchemaVersion, *_: Any, - RelatedCryptoMaterialType - RelatedCryptoMaterialState - ProtocolPropertiesType -- IdentityField -- AnalysisTechnique """ # add new test cases above this line From 44a98efb1c3c625b71ba9c2b32a54bd9006965af Mon Sep 17 00:00:00 2001 From: Jan Kowalleck Date: Mon, 8 Jun 2026 13:27:07 +0200 Subject: [PATCH 07/19] autopep8 Signed-off-by: Jan Kowalleck --- tests/test_enums.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/test_enums.py b/tests/test_enums.py index 5025acca9..1a66acebd 100644 --- a/tests/test_enums.py +++ b/tests/test_enums.py @@ -541,7 +541,6 @@ def test_cases_render_valid(self, of: OutputFormat, sv: SchemaVersion, *_: Any, super()._test_cases_render(bom, of, sv) - @ddt class TestEnumIdentityField(_EnumTestCase): @@ -599,7 +598,6 @@ def test_cases_render_valid(self, of: OutputFormat, sv: SchemaVersion, *_: Any, super()._test_cases_render(bom, of, sv) - """ missing: - CryptoAssetType From ec38b2ee9f21c0f02a0ddea0b376035de81be291 Mon Sep 17 00:00:00 2001 From: Jan Kowalleck Date: Mon, 8 Jun 2026 13:27:24 +0200 Subject: [PATCH 08/19] test data Signed-off-by: Jan Kowalleck --- .../enum_AnalysisTechnique-1.0.xml.bin | 10 ++ .../enum_AnalysisTechnique-1.1.xml.bin | 9 ++ .../enum_AnalysisTechnique-1.2.json.bin | 23 +++++ .../enum_AnalysisTechnique-1.2.xml.bin | 15 +++ .../enum_AnalysisTechnique-1.3.json.bin | 24 +++++ .../enum_AnalysisTechnique-1.3.xml.bin | 16 ++++ .../enum_AnalysisTechnique-1.4.json.bin | 23 +++++ .../enum_AnalysisTechnique-1.4.xml.bin | 15 +++ .../enum_AnalysisTechnique-1.5.json.bin | 89 ++++++++++++++++++ .../enum_AnalysisTechnique-1.5.xml.bin | 75 +++++++++++++++ .../enum_AnalysisTechnique-1.6.json.bin | 91 +++++++++++++++++++ .../enum_AnalysisTechnique-1.6.xml.bin | 75 +++++++++++++++ .../enum_AnalysisTechnique-1.7.json.bin | 91 +++++++++++++++++++ .../enum_AnalysisTechnique-1.7.xml.bin | 75 +++++++++++++++ .../snapshots/enum_IdentityField-1.0.xml.bin | 10 ++ .../snapshots/enum_IdentityField-1.1.xml.bin | 9 ++ .../snapshots/enum_IdentityField-1.2.json.bin | 23 +++++ .../snapshots/enum_IdentityField-1.2.xml.bin | 15 +++ .../snapshots/enum_IdentityField-1.3.json.bin | 24 +++++ .../snapshots/enum_IdentityField-1.3.xml.bin | 16 ++++ .../snapshots/enum_IdentityField-1.4.json.bin | 23 +++++ .../snapshots/enum_IdentityField-1.4.xml.bin | 15 +++ .../snapshots/enum_IdentityField-1.5.json.bin | 37 ++++++++ .../snapshots/enum_IdentityField-1.5.xml.bin | 23 +++++ .../snapshots/enum_IdentityField-1.6.json.bin | 72 +++++++++++++++ .../snapshots/enum_IdentityField-1.6.xml.bin | 56 ++++++++++++ .../snapshots/enum_IdentityField-1.7.json.bin | 72 +++++++++++++++ .../snapshots/enum_IdentityField-1.7.xml.bin | 56 ++++++++++++ 28 files changed, 1082 insertions(+) create mode 100644 tests/_data/snapshots/enum_AnalysisTechnique-1.0.xml.bin create mode 100644 tests/_data/snapshots/enum_AnalysisTechnique-1.1.xml.bin create mode 100644 tests/_data/snapshots/enum_AnalysisTechnique-1.2.json.bin create mode 100644 tests/_data/snapshots/enum_AnalysisTechnique-1.2.xml.bin create mode 100644 tests/_data/snapshots/enum_AnalysisTechnique-1.3.json.bin create mode 100644 tests/_data/snapshots/enum_AnalysisTechnique-1.3.xml.bin create mode 100644 tests/_data/snapshots/enum_AnalysisTechnique-1.4.json.bin create mode 100644 tests/_data/snapshots/enum_AnalysisTechnique-1.4.xml.bin create mode 100644 tests/_data/snapshots/enum_AnalysisTechnique-1.5.json.bin create mode 100644 tests/_data/snapshots/enum_AnalysisTechnique-1.5.xml.bin create mode 100644 tests/_data/snapshots/enum_AnalysisTechnique-1.6.json.bin create mode 100644 tests/_data/snapshots/enum_AnalysisTechnique-1.6.xml.bin create mode 100644 tests/_data/snapshots/enum_AnalysisTechnique-1.7.json.bin create mode 100644 tests/_data/snapshots/enum_AnalysisTechnique-1.7.xml.bin create mode 100644 tests/_data/snapshots/enum_IdentityField-1.0.xml.bin create mode 100644 tests/_data/snapshots/enum_IdentityField-1.1.xml.bin create mode 100644 tests/_data/snapshots/enum_IdentityField-1.2.json.bin create mode 100644 tests/_data/snapshots/enum_IdentityField-1.2.xml.bin create mode 100644 tests/_data/snapshots/enum_IdentityField-1.3.json.bin create mode 100644 tests/_data/snapshots/enum_IdentityField-1.3.xml.bin create mode 100644 tests/_data/snapshots/enum_IdentityField-1.4.json.bin create mode 100644 tests/_data/snapshots/enum_IdentityField-1.4.xml.bin create mode 100644 tests/_data/snapshots/enum_IdentityField-1.5.json.bin create mode 100644 tests/_data/snapshots/enum_IdentityField-1.5.xml.bin create mode 100644 tests/_data/snapshots/enum_IdentityField-1.6.json.bin create mode 100644 tests/_data/snapshots/enum_IdentityField-1.6.xml.bin create mode 100644 tests/_data/snapshots/enum_IdentityField-1.7.json.bin create mode 100644 tests/_data/snapshots/enum_IdentityField-1.7.xml.bin diff --git a/tests/_data/snapshots/enum_AnalysisTechnique-1.0.xml.bin b/tests/_data/snapshots/enum_AnalysisTechnique-1.0.xml.bin new file mode 100644 index 000000000..068b881e8 --- /dev/null +++ b/tests/_data/snapshots/enum_AnalysisTechnique-1.0.xml.bin @@ -0,0 +1,10 @@ + + + + + dummy + + false + + + diff --git a/tests/_data/snapshots/enum_AnalysisTechnique-1.1.xml.bin b/tests/_data/snapshots/enum_AnalysisTechnique-1.1.xml.bin new file mode 100644 index 000000000..6212e7a1e --- /dev/null +++ b/tests/_data/snapshots/enum_AnalysisTechnique-1.1.xml.bin @@ -0,0 +1,9 @@ + + + + + dummy + + + + diff --git a/tests/_data/snapshots/enum_AnalysisTechnique-1.2.json.bin b/tests/_data/snapshots/enum_AnalysisTechnique-1.2.json.bin new file mode 100644 index 000000000..e1304da3c --- /dev/null +++ b/tests/_data/snapshots/enum_AnalysisTechnique-1.2.json.bin @@ -0,0 +1,23 @@ +{ + "components": [ + { + "bom-ref": "dummy", + "name": "dummy", + "type": "library", + "version": "" + } + ], + "dependencies": [ + { + "ref": "dummy" + } + ], + "metadata": { + "timestamp": "2023-01-07T13:44:32.312678+00:00" + }, + "serialNumber": "urn:uuid:1441d33a-e0fc-45b5-af3b-61ee52a88bac", + "version": 1, + "$schema": "http://cyclonedx.org/schema/bom-1.2b.schema.json", + "bomFormat": "CycloneDX", + "specVersion": "1.2" +} \ No newline at end of file diff --git a/tests/_data/snapshots/enum_AnalysisTechnique-1.2.xml.bin b/tests/_data/snapshots/enum_AnalysisTechnique-1.2.xml.bin new file mode 100644 index 000000000..d6f32a853 --- /dev/null +++ b/tests/_data/snapshots/enum_AnalysisTechnique-1.2.xml.bin @@ -0,0 +1,15 @@ + + + + 2023-01-07T13:44:32.312678+00:00 + + + + dummy + + + + + + + diff --git a/tests/_data/snapshots/enum_AnalysisTechnique-1.3.json.bin b/tests/_data/snapshots/enum_AnalysisTechnique-1.3.json.bin new file mode 100644 index 000000000..2b110ae7e --- /dev/null +++ b/tests/_data/snapshots/enum_AnalysisTechnique-1.3.json.bin @@ -0,0 +1,24 @@ +{ + "components": [ + { + "bom-ref": "dummy", + "evidence": {}, + "name": "dummy", + "type": "library", + "version": "" + } + ], + "dependencies": [ + { + "ref": "dummy" + } + ], + "metadata": { + "timestamp": "2023-01-07T13:44:32.312678+00:00" + }, + "serialNumber": "urn:uuid:1441d33a-e0fc-45b5-af3b-61ee52a88bac", + "version": 1, + "$schema": "http://cyclonedx.org/schema/bom-1.3a.schema.json", + "bomFormat": "CycloneDX", + "specVersion": "1.3" +} \ No newline at end of file diff --git a/tests/_data/snapshots/enum_AnalysisTechnique-1.3.xml.bin b/tests/_data/snapshots/enum_AnalysisTechnique-1.3.xml.bin new file mode 100644 index 000000000..98358e5d9 --- /dev/null +++ b/tests/_data/snapshots/enum_AnalysisTechnique-1.3.xml.bin @@ -0,0 +1,16 @@ + + + + 2023-01-07T13:44:32.312678+00:00 + + + + dummy + + + + + + + + diff --git a/tests/_data/snapshots/enum_AnalysisTechnique-1.4.json.bin b/tests/_data/snapshots/enum_AnalysisTechnique-1.4.json.bin new file mode 100644 index 000000000..c063eda5d --- /dev/null +++ b/tests/_data/snapshots/enum_AnalysisTechnique-1.4.json.bin @@ -0,0 +1,23 @@ +{ + "components": [ + { + "bom-ref": "dummy", + "evidence": {}, + "name": "dummy", + "type": "library" + } + ], + "dependencies": [ + { + "ref": "dummy" + } + ], + "metadata": { + "timestamp": "2023-01-07T13:44:32.312678+00:00" + }, + "serialNumber": "urn:uuid:1441d33a-e0fc-45b5-af3b-61ee52a88bac", + "version": 1, + "$schema": "http://cyclonedx.org/schema/bom-1.4.schema.json", + "bomFormat": "CycloneDX", + "specVersion": "1.4" +} \ No newline at end of file diff --git a/tests/_data/snapshots/enum_AnalysisTechnique-1.4.xml.bin b/tests/_data/snapshots/enum_AnalysisTechnique-1.4.xml.bin new file mode 100644 index 000000000..91e492a28 --- /dev/null +++ b/tests/_data/snapshots/enum_AnalysisTechnique-1.4.xml.bin @@ -0,0 +1,15 @@ + + + + 2023-01-07T13:44:32.312678+00:00 + + + + dummy + + + + + + + diff --git a/tests/_data/snapshots/enum_AnalysisTechnique-1.5.json.bin b/tests/_data/snapshots/enum_AnalysisTechnique-1.5.json.bin new file mode 100644 index 000000000..deb143c34 --- /dev/null +++ b/tests/_data/snapshots/enum_AnalysisTechnique-1.5.json.bin @@ -0,0 +1,89 @@ +{ + "components": [ + { + "bom-ref": "dummy", + "evidence": { + "identity": { + "field": "name", + "methods": [ + { + "confidence": 1.0, + "technique": "ast-fingerprint", + "value": "AnalysisTechnique: AST_FINGERPRINT" + }, + { + "confidence": 1.0, + "technique": "attestation", + "value": "AnalysisTechnique: ATTESTATION" + }, + { + "confidence": 1.0, + "technique": "binary-analysis", + "value": "AnalysisTechnique: BINARY_ANALYSIS" + }, + { + "confidence": 1.0, + "technique": "dynamic-analysis", + "value": "AnalysisTechnique: DYNAMIC_ANALYSIS" + }, + { + "confidence": 1.0, + "technique": "filename", + "value": "AnalysisTechnique: FILENAME" + }, + { + "confidence": 1.0, + "technique": "hash-comparison", + "value": "AnalysisTechnique: HASH_COMPARISON" + }, + { + "confidence": 1.0, + "technique": "instrumentation", + "value": "AnalysisTechnique: INSTRUMENTATION" + }, + { + "confidence": 1.0, + "technique": "manifest-analysis", + "value": "AnalysisTechnique: MANIFEST_ANALYSIS" + }, + { + "confidence": 1.0, + "technique": "other", + "value": "AnalysisTechnique: OTHER" + }, + { + "confidence": 1.0, + "technique": "source-code-analysis", + "value": "AnalysisTechnique: SOURCE_CODE_ANALYSIS" + } + ] + } + }, + "name": "dummy", + "type": "library" + } + ], + "dependencies": [ + { + "ref": "dummy" + } + ], + "metadata": { + "timestamp": "2023-01-07T13:44:32.312678+00:00" + }, + "properties": [ + { + "name": "key1", + "value": "val1" + }, + { + "name": "key2", + "value": "val2" + } + ], + "serialNumber": "urn:uuid:1441d33a-e0fc-45b5-af3b-61ee52a88bac", + "version": 1, + "$schema": "http://cyclonedx.org/schema/bom-1.5.schema.json", + "bomFormat": "CycloneDX", + "specVersion": "1.5" +} \ No newline at end of file diff --git a/tests/_data/snapshots/enum_AnalysisTechnique-1.5.xml.bin b/tests/_data/snapshots/enum_AnalysisTechnique-1.5.xml.bin new file mode 100644 index 000000000..d64884a07 --- /dev/null +++ b/tests/_data/snapshots/enum_AnalysisTechnique-1.5.xml.bin @@ -0,0 +1,75 @@ + + + + 2023-01-07T13:44:32.312678+00:00 + + + + dummy + + + name + + + ast-fingerprint + 1 + AnalysisTechnique: AST_FINGERPRINT + + + attestation + 1 + AnalysisTechnique: ATTESTATION + + + binary-analysis + 1 + AnalysisTechnique: BINARY_ANALYSIS + + + dynamic-analysis + 1 + AnalysisTechnique: DYNAMIC_ANALYSIS + + + filename + 1 + AnalysisTechnique: FILENAME + + + hash-comparison + 1 + AnalysisTechnique: HASH_COMPARISON + + + instrumentation + 1 + AnalysisTechnique: INSTRUMENTATION + + + manifest-analysis + 1 + AnalysisTechnique: MANIFEST_ANALYSIS + + + other + 1 + AnalysisTechnique: OTHER + + + source-code-analysis + 1 + AnalysisTechnique: SOURCE_CODE_ANALYSIS + + + + + + + + + + + val1 + val2 + + diff --git a/tests/_data/snapshots/enum_AnalysisTechnique-1.6.json.bin b/tests/_data/snapshots/enum_AnalysisTechnique-1.6.json.bin new file mode 100644 index 000000000..017ab1a24 --- /dev/null +++ b/tests/_data/snapshots/enum_AnalysisTechnique-1.6.json.bin @@ -0,0 +1,91 @@ +{ + "components": [ + { + "bom-ref": "dummy", + "evidence": { + "identity": [ + { + "field": "name", + "methods": [ + { + "confidence": 1.0, + "technique": "ast-fingerprint", + "value": "AnalysisTechnique: AST_FINGERPRINT" + }, + { + "confidence": 1.0, + "technique": "attestation", + "value": "AnalysisTechnique: ATTESTATION" + }, + { + "confidence": 1.0, + "technique": "binary-analysis", + "value": "AnalysisTechnique: BINARY_ANALYSIS" + }, + { + "confidence": 1.0, + "technique": "dynamic-analysis", + "value": "AnalysisTechnique: DYNAMIC_ANALYSIS" + }, + { + "confidence": 1.0, + "technique": "filename", + "value": "AnalysisTechnique: FILENAME" + }, + { + "confidence": 1.0, + "technique": "hash-comparison", + "value": "AnalysisTechnique: HASH_COMPARISON" + }, + { + "confidence": 1.0, + "technique": "instrumentation", + "value": "AnalysisTechnique: INSTRUMENTATION" + }, + { + "confidence": 1.0, + "technique": "manifest-analysis", + "value": "AnalysisTechnique: MANIFEST_ANALYSIS" + }, + { + "confidence": 1.0, + "technique": "other", + "value": "AnalysisTechnique: OTHER" + }, + { + "confidence": 1.0, + "technique": "source-code-analysis", + "value": "AnalysisTechnique: SOURCE_CODE_ANALYSIS" + } + ] + } + ] + }, + "name": "dummy", + "type": "library" + } + ], + "dependencies": [ + { + "ref": "dummy" + } + ], + "metadata": { + "timestamp": "2023-01-07T13:44:32.312678+00:00" + }, + "properties": [ + { + "name": "key1", + "value": "val1" + }, + { + "name": "key2", + "value": "val2" + } + ], + "serialNumber": "urn:uuid:1441d33a-e0fc-45b5-af3b-61ee52a88bac", + "version": 1, + "$schema": "http://cyclonedx.org/schema/bom-1.6.schema.json", + "bomFormat": "CycloneDX", + "specVersion": "1.6" +} \ No newline at end of file diff --git a/tests/_data/snapshots/enum_AnalysisTechnique-1.6.xml.bin b/tests/_data/snapshots/enum_AnalysisTechnique-1.6.xml.bin new file mode 100644 index 000000000..130e9c2c5 --- /dev/null +++ b/tests/_data/snapshots/enum_AnalysisTechnique-1.6.xml.bin @@ -0,0 +1,75 @@ + + + + 2023-01-07T13:44:32.312678+00:00 + + + + dummy + + + name + + + ast-fingerprint + 1 + AnalysisTechnique: AST_FINGERPRINT + + + attestation + 1 + AnalysisTechnique: ATTESTATION + + + binary-analysis + 1 + AnalysisTechnique: BINARY_ANALYSIS + + + dynamic-analysis + 1 + AnalysisTechnique: DYNAMIC_ANALYSIS + + + filename + 1 + AnalysisTechnique: FILENAME + + + hash-comparison + 1 + AnalysisTechnique: HASH_COMPARISON + + + instrumentation + 1 + AnalysisTechnique: INSTRUMENTATION + + + manifest-analysis + 1 + AnalysisTechnique: MANIFEST_ANALYSIS + + + other + 1 + AnalysisTechnique: OTHER + + + source-code-analysis + 1 + AnalysisTechnique: SOURCE_CODE_ANALYSIS + + + + + + + + + + + val1 + val2 + + diff --git a/tests/_data/snapshots/enum_AnalysisTechnique-1.7.json.bin b/tests/_data/snapshots/enum_AnalysisTechnique-1.7.json.bin new file mode 100644 index 000000000..40641fc89 --- /dev/null +++ b/tests/_data/snapshots/enum_AnalysisTechnique-1.7.json.bin @@ -0,0 +1,91 @@ +{ + "components": [ + { + "bom-ref": "dummy", + "evidence": { + "identity": [ + { + "field": "name", + "methods": [ + { + "confidence": 1.0, + "technique": "ast-fingerprint", + "value": "AnalysisTechnique: AST_FINGERPRINT" + }, + { + "confidence": 1.0, + "technique": "attestation", + "value": "AnalysisTechnique: ATTESTATION" + }, + { + "confidence": 1.0, + "technique": "binary-analysis", + "value": "AnalysisTechnique: BINARY_ANALYSIS" + }, + { + "confidence": 1.0, + "technique": "dynamic-analysis", + "value": "AnalysisTechnique: DYNAMIC_ANALYSIS" + }, + { + "confidence": 1.0, + "technique": "filename", + "value": "AnalysisTechnique: FILENAME" + }, + { + "confidence": 1.0, + "technique": "hash-comparison", + "value": "AnalysisTechnique: HASH_COMPARISON" + }, + { + "confidence": 1.0, + "technique": "instrumentation", + "value": "AnalysisTechnique: INSTRUMENTATION" + }, + { + "confidence": 1.0, + "technique": "manifest-analysis", + "value": "AnalysisTechnique: MANIFEST_ANALYSIS" + }, + { + "confidence": 1.0, + "technique": "other", + "value": "AnalysisTechnique: OTHER" + }, + { + "confidence": 1.0, + "technique": "source-code-analysis", + "value": "AnalysisTechnique: SOURCE_CODE_ANALYSIS" + } + ] + } + ] + }, + "name": "dummy", + "type": "library" + } + ], + "dependencies": [ + { + "ref": "dummy" + } + ], + "metadata": { + "timestamp": "2023-01-07T13:44:32.312678+00:00" + }, + "properties": [ + { + "name": "key1", + "value": "val1" + }, + { + "name": "key2", + "value": "val2" + } + ], + "serialNumber": "urn:uuid:1441d33a-e0fc-45b5-af3b-61ee52a88bac", + "version": 1, + "$schema": "http://cyclonedx.org/schema/bom-1.7.schema.json", + "bomFormat": "CycloneDX", + "specVersion": "1.7" +} \ No newline at end of file diff --git a/tests/_data/snapshots/enum_AnalysisTechnique-1.7.xml.bin b/tests/_data/snapshots/enum_AnalysisTechnique-1.7.xml.bin new file mode 100644 index 000000000..d84acf574 --- /dev/null +++ b/tests/_data/snapshots/enum_AnalysisTechnique-1.7.xml.bin @@ -0,0 +1,75 @@ + + + + 2023-01-07T13:44:32.312678+00:00 + + + + dummy + + + name + + + ast-fingerprint + 1 + AnalysisTechnique: AST_FINGERPRINT + + + attestation + 1 + AnalysisTechnique: ATTESTATION + + + binary-analysis + 1 + AnalysisTechnique: BINARY_ANALYSIS + + + dynamic-analysis + 1 + AnalysisTechnique: DYNAMIC_ANALYSIS + + + filename + 1 + AnalysisTechnique: FILENAME + + + hash-comparison + 1 + AnalysisTechnique: HASH_COMPARISON + + + instrumentation + 1 + AnalysisTechnique: INSTRUMENTATION + + + manifest-analysis + 1 + AnalysisTechnique: MANIFEST_ANALYSIS + + + other + 1 + AnalysisTechnique: OTHER + + + source-code-analysis + 1 + AnalysisTechnique: SOURCE_CODE_ANALYSIS + + + + + + + + + + + val1 + val2 + + diff --git a/tests/_data/snapshots/enum_IdentityField-1.0.xml.bin b/tests/_data/snapshots/enum_IdentityField-1.0.xml.bin new file mode 100644 index 000000000..068b881e8 --- /dev/null +++ b/tests/_data/snapshots/enum_IdentityField-1.0.xml.bin @@ -0,0 +1,10 @@ + + + + + dummy + + false + + + diff --git a/tests/_data/snapshots/enum_IdentityField-1.1.xml.bin b/tests/_data/snapshots/enum_IdentityField-1.1.xml.bin new file mode 100644 index 000000000..6212e7a1e --- /dev/null +++ b/tests/_data/snapshots/enum_IdentityField-1.1.xml.bin @@ -0,0 +1,9 @@ + + + + + dummy + + + + diff --git a/tests/_data/snapshots/enum_IdentityField-1.2.json.bin b/tests/_data/snapshots/enum_IdentityField-1.2.json.bin new file mode 100644 index 000000000..e1304da3c --- /dev/null +++ b/tests/_data/snapshots/enum_IdentityField-1.2.json.bin @@ -0,0 +1,23 @@ +{ + "components": [ + { + "bom-ref": "dummy", + "name": "dummy", + "type": "library", + "version": "" + } + ], + "dependencies": [ + { + "ref": "dummy" + } + ], + "metadata": { + "timestamp": "2023-01-07T13:44:32.312678+00:00" + }, + "serialNumber": "urn:uuid:1441d33a-e0fc-45b5-af3b-61ee52a88bac", + "version": 1, + "$schema": "http://cyclonedx.org/schema/bom-1.2b.schema.json", + "bomFormat": "CycloneDX", + "specVersion": "1.2" +} \ No newline at end of file diff --git a/tests/_data/snapshots/enum_IdentityField-1.2.xml.bin b/tests/_data/snapshots/enum_IdentityField-1.2.xml.bin new file mode 100644 index 000000000..d6f32a853 --- /dev/null +++ b/tests/_data/snapshots/enum_IdentityField-1.2.xml.bin @@ -0,0 +1,15 @@ + + + + 2023-01-07T13:44:32.312678+00:00 + + + + dummy + + + + + + + diff --git a/tests/_data/snapshots/enum_IdentityField-1.3.json.bin b/tests/_data/snapshots/enum_IdentityField-1.3.json.bin new file mode 100644 index 000000000..2b110ae7e --- /dev/null +++ b/tests/_data/snapshots/enum_IdentityField-1.3.json.bin @@ -0,0 +1,24 @@ +{ + "components": [ + { + "bom-ref": "dummy", + "evidence": {}, + "name": "dummy", + "type": "library", + "version": "" + } + ], + "dependencies": [ + { + "ref": "dummy" + } + ], + "metadata": { + "timestamp": "2023-01-07T13:44:32.312678+00:00" + }, + "serialNumber": "urn:uuid:1441d33a-e0fc-45b5-af3b-61ee52a88bac", + "version": 1, + "$schema": "http://cyclonedx.org/schema/bom-1.3a.schema.json", + "bomFormat": "CycloneDX", + "specVersion": "1.3" +} \ No newline at end of file diff --git a/tests/_data/snapshots/enum_IdentityField-1.3.xml.bin b/tests/_data/snapshots/enum_IdentityField-1.3.xml.bin new file mode 100644 index 000000000..98358e5d9 --- /dev/null +++ b/tests/_data/snapshots/enum_IdentityField-1.3.xml.bin @@ -0,0 +1,16 @@ + + + + 2023-01-07T13:44:32.312678+00:00 + + + + dummy + + + + + + + + diff --git a/tests/_data/snapshots/enum_IdentityField-1.4.json.bin b/tests/_data/snapshots/enum_IdentityField-1.4.json.bin new file mode 100644 index 000000000..c063eda5d --- /dev/null +++ b/tests/_data/snapshots/enum_IdentityField-1.4.json.bin @@ -0,0 +1,23 @@ +{ + "components": [ + { + "bom-ref": "dummy", + "evidence": {}, + "name": "dummy", + "type": "library" + } + ], + "dependencies": [ + { + "ref": "dummy" + } + ], + "metadata": { + "timestamp": "2023-01-07T13:44:32.312678+00:00" + }, + "serialNumber": "urn:uuid:1441d33a-e0fc-45b5-af3b-61ee52a88bac", + "version": 1, + "$schema": "http://cyclonedx.org/schema/bom-1.4.schema.json", + "bomFormat": "CycloneDX", + "specVersion": "1.4" +} \ No newline at end of file diff --git a/tests/_data/snapshots/enum_IdentityField-1.4.xml.bin b/tests/_data/snapshots/enum_IdentityField-1.4.xml.bin new file mode 100644 index 000000000..91e492a28 --- /dev/null +++ b/tests/_data/snapshots/enum_IdentityField-1.4.xml.bin @@ -0,0 +1,15 @@ + + + + 2023-01-07T13:44:32.312678+00:00 + + + + dummy + + + + + + + diff --git a/tests/_data/snapshots/enum_IdentityField-1.5.json.bin b/tests/_data/snapshots/enum_IdentityField-1.5.json.bin new file mode 100644 index 000000000..44c3b4ad5 --- /dev/null +++ b/tests/_data/snapshots/enum_IdentityField-1.5.json.bin @@ -0,0 +1,37 @@ +{ + "components": [ + { + "bom-ref": "dummy", + "evidence": { + "identity": { + "field": "cpe" + } + }, + "name": "dummy", + "type": "library" + } + ], + "dependencies": [ + { + "ref": "dummy" + } + ], + "metadata": { + "timestamp": "2023-01-07T13:44:32.312678+00:00" + }, + "properties": [ + { + "name": "key1", + "value": "val1" + }, + { + "name": "key2", + "value": "val2" + } + ], + "serialNumber": "urn:uuid:1441d33a-e0fc-45b5-af3b-61ee52a88bac", + "version": 1, + "$schema": "http://cyclonedx.org/schema/bom-1.5.schema.json", + "bomFormat": "CycloneDX", + "specVersion": "1.5" +} \ No newline at end of file diff --git a/tests/_data/snapshots/enum_IdentityField-1.5.xml.bin b/tests/_data/snapshots/enum_IdentityField-1.5.xml.bin new file mode 100644 index 000000000..fde866a5b --- /dev/null +++ b/tests/_data/snapshots/enum_IdentityField-1.5.xml.bin @@ -0,0 +1,23 @@ + + + + 2023-01-07T13:44:32.312678+00:00 + + + + dummy + + + cpe + + + + + + + + + val1 + val2 + + diff --git a/tests/_data/snapshots/enum_IdentityField-1.6.json.bin b/tests/_data/snapshots/enum_IdentityField-1.6.json.bin new file mode 100644 index 000000000..2e3c30deb --- /dev/null +++ b/tests/_data/snapshots/enum_IdentityField-1.6.json.bin @@ -0,0 +1,72 @@ +{ + "components": [ + { + "bom-ref": "dummy", + "evidence": { + "identity": [ + { + "concludedValue": "CPE", + "field": "cpe" + }, + { + "concludedValue": "GROUP", + "field": "group" + }, + { + "concludedValue": "HASH", + "field": "hash" + }, + { + "concludedValue": "NAME", + "field": "name" + }, + { + "concludedValue": "OMNIBOR_ID", + "field": "omniborId" + }, + { + "concludedValue": "PURL", + "field": "purl" + }, + { + "concludedValue": "SWHID", + "field": "swhid" + }, + { + "concludedValue": "SWID", + "field": "swid" + }, + { + "concludedValue": "VERSION", + "field": "version" + } + ] + }, + "name": "dummy", + "type": "library" + } + ], + "dependencies": [ + { + "ref": "dummy" + } + ], + "metadata": { + "timestamp": "2023-01-07T13:44:32.312678+00:00" + }, + "properties": [ + { + "name": "key1", + "value": "val1" + }, + { + "name": "key2", + "value": "val2" + } + ], + "serialNumber": "urn:uuid:1441d33a-e0fc-45b5-af3b-61ee52a88bac", + "version": 1, + "$schema": "http://cyclonedx.org/schema/bom-1.6.schema.json", + "bomFormat": "CycloneDX", + "specVersion": "1.6" +} \ No newline at end of file diff --git a/tests/_data/snapshots/enum_IdentityField-1.6.xml.bin b/tests/_data/snapshots/enum_IdentityField-1.6.xml.bin new file mode 100644 index 000000000..8a66b5203 --- /dev/null +++ b/tests/_data/snapshots/enum_IdentityField-1.6.xml.bin @@ -0,0 +1,56 @@ + + + + 2023-01-07T13:44:32.312678+00:00 + + + + dummy + + + cpe + CPE + + + group + GROUP + + + hash + HASH + + + name + NAME + + + omniborId + OMNIBOR_ID + + + purl + PURL + + + swhid + SWHID + + + swid + SWID + + + version + VERSION + + + + + + + + + val1 + val2 + + diff --git a/tests/_data/snapshots/enum_IdentityField-1.7.json.bin b/tests/_data/snapshots/enum_IdentityField-1.7.json.bin new file mode 100644 index 000000000..acd988ce2 --- /dev/null +++ b/tests/_data/snapshots/enum_IdentityField-1.7.json.bin @@ -0,0 +1,72 @@ +{ + "components": [ + { + "bom-ref": "dummy", + "evidence": { + "identity": [ + { + "concludedValue": "CPE", + "field": "cpe" + }, + { + "concludedValue": "GROUP", + "field": "group" + }, + { + "concludedValue": "HASH", + "field": "hash" + }, + { + "concludedValue": "NAME", + "field": "name" + }, + { + "concludedValue": "OMNIBOR_ID", + "field": "omniborId" + }, + { + "concludedValue": "PURL", + "field": "purl" + }, + { + "concludedValue": "SWHID", + "field": "swhid" + }, + { + "concludedValue": "SWID", + "field": "swid" + }, + { + "concludedValue": "VERSION", + "field": "version" + } + ] + }, + "name": "dummy", + "type": "library" + } + ], + "dependencies": [ + { + "ref": "dummy" + } + ], + "metadata": { + "timestamp": "2023-01-07T13:44:32.312678+00:00" + }, + "properties": [ + { + "name": "key1", + "value": "val1" + }, + { + "name": "key2", + "value": "val2" + } + ], + "serialNumber": "urn:uuid:1441d33a-e0fc-45b5-af3b-61ee52a88bac", + "version": 1, + "$schema": "http://cyclonedx.org/schema/bom-1.7.schema.json", + "bomFormat": "CycloneDX", + "specVersion": "1.7" +} \ No newline at end of file diff --git a/tests/_data/snapshots/enum_IdentityField-1.7.xml.bin b/tests/_data/snapshots/enum_IdentityField-1.7.xml.bin new file mode 100644 index 000000000..91144a020 --- /dev/null +++ b/tests/_data/snapshots/enum_IdentityField-1.7.xml.bin @@ -0,0 +1,56 @@ + + + + 2023-01-07T13:44:32.312678+00:00 + + + + dummy + + + cpe + CPE + + + group + GROUP + + + hash + HASH + + + name + NAME + + + omniborId + OMNIBOR_ID + + + purl + PURL + + + swhid + SWHID + + + swid + SWID + + + version + VERSION + + + + + + + + + val1 + val2 + + From f4ae307db933b4ae8c7270139ab30761317ad27a Mon Sep 17 00:00:00 2001 From: Jan Kowalleck Date: Mon, 8 Jun 2026 13:33:47 +0200 Subject: [PATCH 09/19] tests: TestEnumIdentityField & TestEnumAnalysisTechnique Signed-off-by: Jan Kowalleck --- tests/test_enums.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/test_enums.py b/tests/test_enums.py index 1a66acebd..a463414fa 100644 --- a/tests/test_enums.py +++ b/tests/test_enums.py @@ -545,11 +545,11 @@ def test_cases_render_valid(self, of: OutputFormat, sv: SchemaVersion, *_: Any, class TestEnumIdentityField(_EnumTestCase): @idata(set(chain( - dp_cases_from_xml_schemas(f"./{SCHEMA_NS}simpleType[@name='licenseAcknowledgementEnumerationType']"), - dp_cases_from_json_schemas('definitions', 'licenseAcknowledgementEnumeration'), + dp_cases_from_xml_schemas(f"./{SCHEMA_NS}simpleType[@name='identityFieldType']"), + dp_cases_from_json_schemas('definitions', 'componentIdentityEvidence', 'properties', 'field'), ))) def test_knows_value(self, value: str) -> None: - super()._test_knows_value(LicenseAcknowledgement, value) + super()._test_knows_value(IdentityField, value) @named_data(*NAMED_OF_SV) def test_cases_render_valid(self, of: OutputFormat, sv: SchemaVersion, *_: Any, **__: Any) -> None: @@ -570,11 +570,11 @@ def test_cases_render_valid(self, of: OutputFormat, sv: SchemaVersion, *_: Any, class TestEnumAnalysisTechnique(_EnumTestCase): @idata(set(chain( - dp_cases_from_xml_schemas(f"./{SCHEMA_NS}simpleType[@name='licenseAcknowledgementEnumerationType']"), - dp_cases_from_json_schemas('definitions', 'licenseAcknowledgementEnumeration'), + dp_cases_from_xml_schemas(f"./{SCHEMA_NS}simpleType[@name='evidenceTechnique']"), + dp_cases_from_json_schemas('definitions', 'componentIdentityEvidence', 'properties', 'methods', 'items', 'properties', 'technique'), ))) def test_knows_value(self, value: str) -> None: - super()._test_knows_value(LicenseAcknowledgement, value) + super()._test_knows_value(AnalysisTechnique, value) @named_data(*NAMED_OF_SV) def test_cases_render_valid(self, of: OutputFormat, sv: SchemaVersion, *_: Any, **__: Any) -> None: From 4868e2d6cd8e9a3b962ce4c63dd7e24c1329291a Mon Sep 17 00:00:00 2001 From: Jan Kowalleck Date: Mon, 8 Jun 2026 13:34:08 +0200 Subject: [PATCH 10/19] autopep8 Signed-off-by: Jan Kowalleck --- tests/test_enums.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/test_enums.py b/tests/test_enums.py index a463414fa..084177627 100644 --- a/tests/test_enums.py +++ b/tests/test_enums.py @@ -571,7 +571,8 @@ class TestEnumAnalysisTechnique(_EnumTestCase): @idata(set(chain( dp_cases_from_xml_schemas(f"./{SCHEMA_NS}simpleType[@name='evidenceTechnique']"), - dp_cases_from_json_schemas('definitions', 'componentIdentityEvidence', 'properties', 'methods', 'items', 'properties', 'technique'), + dp_cases_from_json_schemas('definitions', 'componentIdentityEvidence', 'properties', + 'methods', 'items', 'properties', 'technique'), ))) def test_knows_value(self, value: str) -> None: super()._test_knows_value(AnalysisTechnique, value) From b29e49c4629f5bae569075467fb8253cabafb71e Mon Sep 17 00:00:00 2001 From: Jan Kowalleck Date: Mon, 15 Jun 2026 10:58:33 +0200 Subject: [PATCH 11/19] tests: enum CryptoAssetType Signed-off-by: Jan Kowalleck --- tests/test_enums.py | 78 +++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 72 insertions(+), 6 deletions(-) diff --git a/tests/test_enums.py b/tests/test_enums.py index 084177627..187c8cd2a 100644 --- a/tests/test_enums.py +++ b/tests/test_enums.py @@ -36,6 +36,7 @@ from cyclonedx.model.bom import Bom, BomMetaData, DistributionConstraints, TlpClassification from cyclonedx.model.component import Component, Patch, Pedigree from cyclonedx.model.component_evidence import ComponentEvidence, Identity as CEIdentity, Method as CEMethod +from cyclonedx.model.crypto import CryptoProperties from cyclonedx.model.issue import IssueType from cyclonedx.model.license import DisjunctiveLicense from cyclonedx.model.lifecycle import LifecyclePhase, PredefinedLifecycle @@ -87,6 +88,19 @@ VulnerabilityScoreSource, VulnerabilitySeverity, ) +from cyclonedx.model.crypto import ( # isort:skip + CryptoAssetType, + CryptoPrimitive, + CryptoExecutionEnvironment, + CryptoImplementationPlatform, + CryptoCertificationLevel, + CryptoMode, + CryptoPadding, + CryptoFunction, + RelatedCryptoMaterialType, + RelatedCryptoMaterialState, + ProtocolPropertiesType, +) # endregion SUT @@ -97,14 +111,18 @@ def dp_cases_from_xml_schema(sf: str, xpath: str) -> Generator[str, None, None]: for el in xml_parse(sf).iterfind(f'{xpath}/{SCHEMA_NS}restriction/{SCHEMA_NS}enumeration'): # nosec B314 yield el.get('value') + # warn if no such structure -def dp_cases_from_xml_schemas(xpath: str) -> Generator[str, None, None]: +def dp_cases_from_xml_schemas(xpath: str) -> set[str]: + cases: set[str] = set() for sf in SCHEMA_XML.values(): if sf is None: continue - yield from dp_cases_from_xml_schema(sf, xpath) - + cases.update(dp_cases_from_xml_schema(sf, xpath)) + if len(cases) == 0: + raise ValueError(f'no values for xpath: {xpath!r}') + return cases def dp_cases_from_json_schema(sf: str, jsonpointer: Iterable[str]) -> Generator[str, None, None]: with open(sf) as sfh: @@ -113,15 +131,20 @@ def dp_cases_from_json_schema(sf: str, jsonpointer: Iterable[str]) -> Generator[ for pp in jsonpointer: data = data[pp] except KeyError: + # warn if no such structure return yield from data['enum'] -def dp_cases_from_json_schemas(*jsonpointer: str) -> Generator[str, None, None]: +def dp_cases_from_json_schemas(*jsonpointer: str) -> set[str]: + cases: set[str] = set() for sf in SCHEMA_JSON.values(): if sf is None: continue - yield from dp_cases_from_json_schema(sf, jsonpointer) + cases.update(dp_cases_from_json_schema(sf, jsonpointer)) + if len(cases) == 0: + raise ValueError(f'no values for jsonpointer: {jsonpointer!r}') + return cases UNSUPPORTED_OF_SV = frozenset([ @@ -490,7 +513,7 @@ class TestEnumLifecyclePhase(_EnumTestCase): @idata(set(chain( dp_cases_from_xml_schemas(f"./{SCHEMA_NS}simpleType[@name='lifecyclePhaseType']"), - dp_cases_from_json_schemas('definitions', 'metadata', 'properties', 'lifecycles', 'items', 'phase'), + dp_cases_from_json_schemas('definitions', 'metadata', 'properties', 'lifecycles', 'items', 'oneOf', 0, 'properties', 'phase'), ))) def test_knows_value(self, value: str) -> None: super()._test_knows_value(LifecyclePhase, value) @@ -598,6 +621,49 @@ def test_cases_render_valid(self, of: OutputFormat, sv: SchemaVersion, *_: Any, ]) super()._test_cases_render(bom, of, sv) +@ddt +class TestEnumCryptoAssetType(_EnumTestCase): + + @idata(set(chain( + dp_cases_from_xml_schemas(f"./{SCHEMA_NS}complexType[@name='cryptoPropertiesType']/{SCHEMA_NS}sequence/{SCHEMA_NS}element[@name='assetType']/{SCHEMA_NS}simpleType"), + dp_cases_from_json_schemas('definitions', 'cryptoProperties', 'properties', 'assetType'), + ))) + def test_knows_value(self, value: str) -> None: + super()._test_knows_value(CryptoAssetType, value) + + @named_data(*(d for d in NAMED_OF_SV if d[2] >= SchemaVersion.V1_6 )) + def test_cases_render_valid(self, of: OutputFormat, sv: SchemaVersion, *_: Any, **__: Any) -> None: + bom = _make_bom( + components=[ + Component( + name=f'CryptoAssetType: {cat.name}', type=ComponentType.CRYPTOGRAPHIC_ASSET, bom_ref=f'dummy-CAT:{cat.name}', + crypto_properties=CryptoProperties( + asset_type=cat + ) + ) for cat in CryptoAssetType + ]) + super()._test_cases_render(bom, of, sv) + +""" +@ddt +class TestEnum...(_EnumTestCase): + + @idata(set(chain( + dp_cases_from_xml_schemas(f"./{SCHEMA_NS}simpleType[@name='...']"), + dp_cases_from_json_schemas('definitions', '...'), + ))) + def test_knows_value(self, value: str) -> None: + super()._test_knows_value(..., value) + + @named_data(*NAMED_OF_SV) + def test_cases_render_valid(self, of: OutputFormat, sv: SchemaVersion, *_: Any, **__: Any) -> None: + bom = _make_bom( + components=[ + ... + ]) + super()._test_cases_render(bom, of, sv) + +""" """ missing: From 4ff6db8471fa4388a624f84a1247a757148474e3 Mon Sep 17 00:00:00 2001 From: Jan Kowalleck Date: Mon, 15 Jun 2026 10:58:38 +0200 Subject: [PATCH 12/19] tests: enum CryptoAssetType Signed-off-by: Jan Kowalleck --- .../enum_CryptoAssetType-1.6.json.bin | 68 +++++++++++++++++++ .../enum_CryptoAssetType-1.6.xml.bin | 42 ++++++++++++ .../enum_CryptoAssetType-1.7.json.bin | 68 +++++++++++++++++++ .../enum_CryptoAssetType-1.7.xml.bin | 42 ++++++++++++ 4 files changed, 220 insertions(+) create mode 100644 tests/_data/snapshots/enum_CryptoAssetType-1.6.json.bin create mode 100644 tests/_data/snapshots/enum_CryptoAssetType-1.6.xml.bin create mode 100644 tests/_data/snapshots/enum_CryptoAssetType-1.7.json.bin create mode 100644 tests/_data/snapshots/enum_CryptoAssetType-1.7.xml.bin diff --git a/tests/_data/snapshots/enum_CryptoAssetType-1.6.json.bin b/tests/_data/snapshots/enum_CryptoAssetType-1.6.json.bin new file mode 100644 index 000000000..dd554d923 --- /dev/null +++ b/tests/_data/snapshots/enum_CryptoAssetType-1.6.json.bin @@ -0,0 +1,68 @@ +{ + "components": [ + { + "bom-ref": "dummy-CAT:ALGORITHM", + "cryptoProperties": { + "assetType": "algorithm" + }, + "name": "CryptoAssetType: ALGORITHM", + "type": "cryptographic-asset" + }, + { + "bom-ref": "dummy-CAT:CERTIFICATE", + "cryptoProperties": { + "assetType": "certificate" + }, + "name": "CryptoAssetType: CERTIFICATE", + "type": "cryptographic-asset" + }, + { + "bom-ref": "dummy-CAT:PROTOCOL", + "cryptoProperties": { + "assetType": "protocol" + }, + "name": "CryptoAssetType: PROTOCOL", + "type": "cryptographic-asset" + }, + { + "bom-ref": "dummy-CAT:RELATED_CRYPTO_MATERIAL", + "cryptoProperties": { + "assetType": "related-crypto-material" + }, + "name": "CryptoAssetType: RELATED_CRYPTO_MATERIAL", + "type": "cryptographic-asset" + } + ], + "dependencies": [ + { + "ref": "dummy-CAT:ALGORITHM" + }, + { + "ref": "dummy-CAT:CERTIFICATE" + }, + { + "ref": "dummy-CAT:PROTOCOL" + }, + { + "ref": "dummy-CAT:RELATED_CRYPTO_MATERIAL" + } + ], + "metadata": { + "timestamp": "2023-01-07T13:44:32.312678+00:00" + }, + "properties": [ + { + "name": "key1", + "value": "val1" + }, + { + "name": "key2", + "value": "val2" + } + ], + "serialNumber": "urn:uuid:1441d33a-e0fc-45b5-af3b-61ee52a88bac", + "version": 1, + "$schema": "http://cyclonedx.org/schema/bom-1.6.schema.json", + "bomFormat": "CycloneDX", + "specVersion": "1.6" +} \ No newline at end of file diff --git a/tests/_data/snapshots/enum_CryptoAssetType-1.6.xml.bin b/tests/_data/snapshots/enum_CryptoAssetType-1.6.xml.bin new file mode 100644 index 000000000..adbaa1af2 --- /dev/null +++ b/tests/_data/snapshots/enum_CryptoAssetType-1.6.xml.bin @@ -0,0 +1,42 @@ + + + + 2023-01-07T13:44:32.312678+00:00 + + + + CryptoAssetType: ALGORITHM + + algorithm + + + + CryptoAssetType: CERTIFICATE + + certificate + + + + CryptoAssetType: PROTOCOL + + protocol + + + + CryptoAssetType: RELATED_CRYPTO_MATERIAL + + related-crypto-material + + + + + + + + + + + val1 + val2 + + diff --git a/tests/_data/snapshots/enum_CryptoAssetType-1.7.json.bin b/tests/_data/snapshots/enum_CryptoAssetType-1.7.json.bin new file mode 100644 index 000000000..d337680a2 --- /dev/null +++ b/tests/_data/snapshots/enum_CryptoAssetType-1.7.json.bin @@ -0,0 +1,68 @@ +{ + "components": [ + { + "bom-ref": "dummy-CAT:ALGORITHM", + "cryptoProperties": { + "assetType": "algorithm" + }, + "name": "CryptoAssetType: ALGORITHM", + "type": "cryptographic-asset" + }, + { + "bom-ref": "dummy-CAT:CERTIFICATE", + "cryptoProperties": { + "assetType": "certificate" + }, + "name": "CryptoAssetType: CERTIFICATE", + "type": "cryptographic-asset" + }, + { + "bom-ref": "dummy-CAT:PROTOCOL", + "cryptoProperties": { + "assetType": "protocol" + }, + "name": "CryptoAssetType: PROTOCOL", + "type": "cryptographic-asset" + }, + { + "bom-ref": "dummy-CAT:RELATED_CRYPTO_MATERIAL", + "cryptoProperties": { + "assetType": "related-crypto-material" + }, + "name": "CryptoAssetType: RELATED_CRYPTO_MATERIAL", + "type": "cryptographic-asset" + } + ], + "dependencies": [ + { + "ref": "dummy-CAT:ALGORITHM" + }, + { + "ref": "dummy-CAT:CERTIFICATE" + }, + { + "ref": "dummy-CAT:PROTOCOL" + }, + { + "ref": "dummy-CAT:RELATED_CRYPTO_MATERIAL" + } + ], + "metadata": { + "timestamp": "2023-01-07T13:44:32.312678+00:00" + }, + "properties": [ + { + "name": "key1", + "value": "val1" + }, + { + "name": "key2", + "value": "val2" + } + ], + "serialNumber": "urn:uuid:1441d33a-e0fc-45b5-af3b-61ee52a88bac", + "version": 1, + "$schema": "http://cyclonedx.org/schema/bom-1.7.schema.json", + "bomFormat": "CycloneDX", + "specVersion": "1.7" +} \ No newline at end of file diff --git a/tests/_data/snapshots/enum_CryptoAssetType-1.7.xml.bin b/tests/_data/snapshots/enum_CryptoAssetType-1.7.xml.bin new file mode 100644 index 000000000..20662c941 --- /dev/null +++ b/tests/_data/snapshots/enum_CryptoAssetType-1.7.xml.bin @@ -0,0 +1,42 @@ + + + + 2023-01-07T13:44:32.312678+00:00 + + + + CryptoAssetType: ALGORITHM + + algorithm + + + + CryptoAssetType: CERTIFICATE + + certificate + + + + CryptoAssetType: PROTOCOL + + protocol + + + + CryptoAssetType: RELATED_CRYPTO_MATERIAL + + related-crypto-material + + + + + + + + + + + val1 + val2 + + From a3f5eea9fdfbc95725be54008537935f75e51978 Mon Sep 17 00:00:00 2001 From: Jan Kowalleck Date: Mon, 15 Jun 2026 11:33:57 +0200 Subject: [PATCH 13/19] tests: enum CryptoPrimitive Signed-off-by: Jan Kowalleck --- cyclonedx/model/crypto.py | 3 +++ tests/test_enums.py | 38 +++++++++++++++++++++++++++++++++----- 2 files changed, 36 insertions(+), 5 deletions(-) diff --git a/cyclonedx/model/crypto.py b/cyclonedx/model/crypto.py index a3d32d0ea..37122e113 100644 --- a/cyclonedx/model/crypto.py +++ b/cyclonedx/model/crypto.py @@ -59,6 +59,8 @@ class CryptoAssetType(str, Enum): @serializable.serializable_enum class CryptoPrimitive(str, Enum): + # TODO: rename to `CryptoAlgorithmPrimitive` + """ This is our internal representation of the cryptoPropertiesType.algorithmProperties.primitive ENUM type within the CycloneDX standard. @@ -83,6 +85,7 @@ class CryptoPrimitive(str, Enum): SIGNATURE = 'signature' STREAM_CIPHER = 'stream-cipher' XOF = 'xof' + # TODO: add `key-wrap` - since CDX1.7key-wrap OTHER = 'other' UNKNOWN = 'unknown' diff --git a/tests/test_enums.py b/tests/test_enums.py index 187c8cd2a..25aec1e0d 100644 --- a/tests/test_enums.py +++ b/tests/test_enums.py @@ -36,7 +36,7 @@ from cyclonedx.model.bom import Bom, BomMetaData, DistributionConstraints, TlpClassification from cyclonedx.model.component import Component, Patch, Pedigree from cyclonedx.model.component_evidence import ComponentEvidence, Identity as CEIdentity, Method as CEMethod -from cyclonedx.model.crypto import CryptoProperties +from cyclonedx.model.crypto import CryptoProperties, AlgorithmProperties from cyclonedx.model.issue import IssueType from cyclonedx.model.license import DisjunctiveLicense from cyclonedx.model.lifecycle import LifecyclePhase, PredefinedLifecycle @@ -636,14 +636,44 @@ def test_cases_render_valid(self, of: OutputFormat, sv: SchemaVersion, *_: Any, bom = _make_bom( components=[ Component( - name=f'CryptoAssetType: {cat.name}', type=ComponentType.CRYPTOGRAPHIC_ASSET, bom_ref=f'dummy-CAT:{cat.name}', - crypto_properties=CryptoProperties( + name=f'CryptoAssetType: {cat.name}', bom_ref=f'dummy-CAT:{cat.name}', + type=ComponentType.CRYPTOGRAPHIC_ASSET, + crypto_properties=CryptoProperties( asset_type=cat ) ) for cat in CryptoAssetType ]) super()._test_cases_render(bom, of, sv) + +@ddt +class TestEnumCryptoPrimitive(_EnumTestCase): + + @idata(set(chain( + dp_cases_from_xml_schemas(f"./{SCHEMA_NS}complexType[@name='cryptoPropertiesType']/{SCHEMA_NS}sequence/{SCHEMA_NS}element[@name='algorithmProperties']/{SCHEMA_NS}complexType/{SCHEMA_NS}sequence/{SCHEMA_NS}element[@name='primitive']/{SCHEMA_NS}simpleType"), + dp_cases_from_json_schemas('definitions', 'cryptoProperties', 'properties', 'algorithmProperties', 'properties', 'primitive'), + ))) + def test_knows_value(self, value: str) -> None: + super()._test_knows_value(CryptoPrimitive, value) + + @named_data(*(d for d in NAMED_OF_SV if d[2] >= SchemaVersion.V1_6 )) + def test_cases_render_valid(self, of: OutputFormat, sv: SchemaVersion, *_: Any, **__: Any) -> None: + bom = _make_bom( + components=[ + Component( + name=f'CryptoPrimitive: {cp.name}', bom_ref=f'dummy-CP:{cp.name}', + type=ComponentType.CRYPTOGRAPHIC_ASSET, + crypto_properties=CryptoProperties( + asset_type=CryptoAssetType.ALGORITHM, + algorithm_properties=AlgorithmProperties( + primitive=cp + ) + ) + ) for cp in CryptoPrimitive + ]) + super()._test_cases_render(bom, of, sv) + + """ @ddt class TestEnum...(_EnumTestCase): @@ -667,8 +697,6 @@ def test_cases_render_valid(self, of: OutputFormat, sv: SchemaVersion, *_: Any, """ missing: -- CryptoAssetType -- CryptoPrimitive - CryptoExecutionEnvironment - CryptoImplementationPlatform - CryptoCertificationLevel From 9129d389d589b834c8b9f07071a2732ce75a8d89 Mon Sep 17 00:00:00 2001 From: Jan Kowalleck Date: Mon, 15 Jun 2026 11:34:01 +0200 Subject: [PATCH 14/19] tests: enum CryptoPrimitive Signed-off-by: Jan Kowalleck --- .../enum_CryptoPrimitive-1.6.json.bin | 234 ++++++++++++++++++ .../enum_CryptoPrimitive-1.6.xml.bin | 164 ++++++++++++ .../enum_CryptoPrimitive-1.7.json.bin | 234 ++++++++++++++++++ .../enum_CryptoPrimitive-1.7.xml.bin | 164 ++++++++++++ 4 files changed, 796 insertions(+) create mode 100644 tests/_data/snapshots/enum_CryptoPrimitive-1.6.json.bin create mode 100644 tests/_data/snapshots/enum_CryptoPrimitive-1.6.xml.bin create mode 100644 tests/_data/snapshots/enum_CryptoPrimitive-1.7.json.bin create mode 100644 tests/_data/snapshots/enum_CryptoPrimitive-1.7.xml.bin diff --git a/tests/_data/snapshots/enum_CryptoPrimitive-1.6.json.bin b/tests/_data/snapshots/enum_CryptoPrimitive-1.6.json.bin new file mode 100644 index 000000000..656f8677c --- /dev/null +++ b/tests/_data/snapshots/enum_CryptoPrimitive-1.6.json.bin @@ -0,0 +1,234 @@ +{ + "components": [ + { + "bom-ref": "dummy-CP:AE", + "cryptoProperties": { + "algorithmProperties": { + "primitive": "ae" + }, + "assetType": "algorithm" + }, + "name": "CryptoPrimitive: AE", + "type": "cryptographic-asset" + }, + { + "bom-ref": "dummy-CP:BLOCK_CIPHER", + "cryptoProperties": { + "algorithmProperties": { + "primitive": "block-cipher" + }, + "assetType": "algorithm" + }, + "name": "CryptoPrimitive: BLOCK_CIPHER", + "type": "cryptographic-asset" + }, + { + "bom-ref": "dummy-CP:COMBINER", + "cryptoProperties": { + "algorithmProperties": { + "primitive": "combiner" + }, + "assetType": "algorithm" + }, + "name": "CryptoPrimitive: COMBINER", + "type": "cryptographic-asset" + }, + { + "bom-ref": "dummy-CP:DRBG", + "cryptoProperties": { + "algorithmProperties": { + "primitive": "drbg" + }, + "assetType": "algorithm" + }, + "name": "CryptoPrimitive: DRBG", + "type": "cryptographic-asset" + }, + { + "bom-ref": "dummy-CP:HASH", + "cryptoProperties": { + "algorithmProperties": { + "primitive": "hash" + }, + "assetType": "algorithm" + }, + "name": "CryptoPrimitive: HASH", + "type": "cryptographic-asset" + }, + { + "bom-ref": "dummy-CP:KDF", + "cryptoProperties": { + "algorithmProperties": { + "primitive": "kdf" + }, + "assetType": "algorithm" + }, + "name": "CryptoPrimitive: KDF", + "type": "cryptographic-asset" + }, + { + "bom-ref": "dummy-CP:KEM", + "cryptoProperties": { + "algorithmProperties": { + "primitive": "kem" + }, + "assetType": "algorithm" + }, + "name": "CryptoPrimitive: KEM", + "type": "cryptographic-asset" + }, + { + "bom-ref": "dummy-CP:KEY_AGREE", + "cryptoProperties": { + "algorithmProperties": { + "primitive": "key-agree" + }, + "assetType": "algorithm" + }, + "name": "CryptoPrimitive: KEY_AGREE", + "type": "cryptographic-asset" + }, + { + "bom-ref": "dummy-CP:MAC", + "cryptoProperties": { + "algorithmProperties": { + "primitive": "mac" + }, + "assetType": "algorithm" + }, + "name": "CryptoPrimitive: MAC", + "type": "cryptographic-asset" + }, + { + "bom-ref": "dummy-CP:OTHER", + "cryptoProperties": { + "algorithmProperties": { + "primitive": "other" + }, + "assetType": "algorithm" + }, + "name": "CryptoPrimitive: OTHER", + "type": "cryptographic-asset" + }, + { + "bom-ref": "dummy-CP:PKE", + "cryptoProperties": { + "algorithmProperties": { + "primitive": "pke" + }, + "assetType": "algorithm" + }, + "name": "CryptoPrimitive: PKE", + "type": "cryptographic-asset" + }, + { + "bom-ref": "dummy-CP:SIGNATURE", + "cryptoProperties": { + "algorithmProperties": { + "primitive": "signature" + }, + "assetType": "algorithm" + }, + "name": "CryptoPrimitive: SIGNATURE", + "type": "cryptographic-asset" + }, + { + "bom-ref": "dummy-CP:STREAM_CIPHER", + "cryptoProperties": { + "algorithmProperties": { + "primitive": "stream-cipher" + }, + "assetType": "algorithm" + }, + "name": "CryptoPrimitive: STREAM_CIPHER", + "type": "cryptographic-asset" + }, + { + "bom-ref": "dummy-CP:UNKNOWN", + "cryptoProperties": { + "algorithmProperties": { + "primitive": "unknown" + }, + "assetType": "algorithm" + }, + "name": "CryptoPrimitive: UNKNOWN", + "type": "cryptographic-asset" + }, + { + "bom-ref": "dummy-CP:XOF", + "cryptoProperties": { + "algorithmProperties": { + "primitive": "xof" + }, + "assetType": "algorithm" + }, + "name": "CryptoPrimitive: XOF", + "type": "cryptographic-asset" + } + ], + "dependencies": [ + { + "ref": "dummy-CP:AE" + }, + { + "ref": "dummy-CP:BLOCK_CIPHER" + }, + { + "ref": "dummy-CP:COMBINER" + }, + { + "ref": "dummy-CP:DRBG" + }, + { + "ref": "dummy-CP:HASH" + }, + { + "ref": "dummy-CP:KDF" + }, + { + "ref": "dummy-CP:KEM" + }, + { + "ref": "dummy-CP:KEY_AGREE" + }, + { + "ref": "dummy-CP:MAC" + }, + { + "ref": "dummy-CP:OTHER" + }, + { + "ref": "dummy-CP:PKE" + }, + { + "ref": "dummy-CP:SIGNATURE" + }, + { + "ref": "dummy-CP:STREAM_CIPHER" + }, + { + "ref": "dummy-CP:UNKNOWN" + }, + { + "ref": "dummy-CP:XOF" + } + ], + "metadata": { + "timestamp": "2023-01-07T13:44:32.312678+00:00" + }, + "properties": [ + { + "name": "key1", + "value": "val1" + }, + { + "name": "key2", + "value": "val2" + } + ], + "serialNumber": "urn:uuid:1441d33a-e0fc-45b5-af3b-61ee52a88bac", + "version": 1, + "$schema": "http://cyclonedx.org/schema/bom-1.6.schema.json", + "bomFormat": "CycloneDX", + "specVersion": "1.6" +} \ No newline at end of file diff --git a/tests/_data/snapshots/enum_CryptoPrimitive-1.6.xml.bin b/tests/_data/snapshots/enum_CryptoPrimitive-1.6.xml.bin new file mode 100644 index 000000000..658a0b6f3 --- /dev/null +++ b/tests/_data/snapshots/enum_CryptoPrimitive-1.6.xml.bin @@ -0,0 +1,164 @@ + + + + 2023-01-07T13:44:32.312678+00:00 + + + + CryptoPrimitive: AE + + algorithm + + ae + + + + + CryptoPrimitive: BLOCK_CIPHER + + algorithm + + block-cipher + + + + + CryptoPrimitive: COMBINER + + algorithm + + combiner + + + + + CryptoPrimitive: DRBG + + algorithm + + drbg + + + + + CryptoPrimitive: HASH + + algorithm + + hash + + + + + CryptoPrimitive: KDF + + algorithm + + kdf + + + + + CryptoPrimitive: KEM + + algorithm + + kem + + + + + CryptoPrimitive: KEY_AGREE + + algorithm + + key-agree + + + + + CryptoPrimitive: MAC + + algorithm + + mac + + + + + CryptoPrimitive: OTHER + + algorithm + + other + + + + + CryptoPrimitive: PKE + + algorithm + + pke + + + + + CryptoPrimitive: SIGNATURE + + algorithm + + signature + + + + + CryptoPrimitive: STREAM_CIPHER + + algorithm + + stream-cipher + + + + + CryptoPrimitive: UNKNOWN + + algorithm + + unknown + + + + + CryptoPrimitive: XOF + + algorithm + + xof + + + + + + + + + + + + + + + + + + + + + + + val1 + val2 + + diff --git a/tests/_data/snapshots/enum_CryptoPrimitive-1.7.json.bin b/tests/_data/snapshots/enum_CryptoPrimitive-1.7.json.bin new file mode 100644 index 000000000..e78b7d81c --- /dev/null +++ b/tests/_data/snapshots/enum_CryptoPrimitive-1.7.json.bin @@ -0,0 +1,234 @@ +{ + "components": [ + { + "bom-ref": "dummy-CP:AE", + "cryptoProperties": { + "algorithmProperties": { + "primitive": "ae" + }, + "assetType": "algorithm" + }, + "name": "CryptoPrimitive: AE", + "type": "cryptographic-asset" + }, + { + "bom-ref": "dummy-CP:BLOCK_CIPHER", + "cryptoProperties": { + "algorithmProperties": { + "primitive": "block-cipher" + }, + "assetType": "algorithm" + }, + "name": "CryptoPrimitive: BLOCK_CIPHER", + "type": "cryptographic-asset" + }, + { + "bom-ref": "dummy-CP:COMBINER", + "cryptoProperties": { + "algorithmProperties": { + "primitive": "combiner" + }, + "assetType": "algorithm" + }, + "name": "CryptoPrimitive: COMBINER", + "type": "cryptographic-asset" + }, + { + "bom-ref": "dummy-CP:DRBG", + "cryptoProperties": { + "algorithmProperties": { + "primitive": "drbg" + }, + "assetType": "algorithm" + }, + "name": "CryptoPrimitive: DRBG", + "type": "cryptographic-asset" + }, + { + "bom-ref": "dummy-CP:HASH", + "cryptoProperties": { + "algorithmProperties": { + "primitive": "hash" + }, + "assetType": "algorithm" + }, + "name": "CryptoPrimitive: HASH", + "type": "cryptographic-asset" + }, + { + "bom-ref": "dummy-CP:KDF", + "cryptoProperties": { + "algorithmProperties": { + "primitive": "kdf" + }, + "assetType": "algorithm" + }, + "name": "CryptoPrimitive: KDF", + "type": "cryptographic-asset" + }, + { + "bom-ref": "dummy-CP:KEM", + "cryptoProperties": { + "algorithmProperties": { + "primitive": "kem" + }, + "assetType": "algorithm" + }, + "name": "CryptoPrimitive: KEM", + "type": "cryptographic-asset" + }, + { + "bom-ref": "dummy-CP:KEY_AGREE", + "cryptoProperties": { + "algorithmProperties": { + "primitive": "key-agree" + }, + "assetType": "algorithm" + }, + "name": "CryptoPrimitive: KEY_AGREE", + "type": "cryptographic-asset" + }, + { + "bom-ref": "dummy-CP:MAC", + "cryptoProperties": { + "algorithmProperties": { + "primitive": "mac" + }, + "assetType": "algorithm" + }, + "name": "CryptoPrimitive: MAC", + "type": "cryptographic-asset" + }, + { + "bom-ref": "dummy-CP:OTHER", + "cryptoProperties": { + "algorithmProperties": { + "primitive": "other" + }, + "assetType": "algorithm" + }, + "name": "CryptoPrimitive: OTHER", + "type": "cryptographic-asset" + }, + { + "bom-ref": "dummy-CP:PKE", + "cryptoProperties": { + "algorithmProperties": { + "primitive": "pke" + }, + "assetType": "algorithm" + }, + "name": "CryptoPrimitive: PKE", + "type": "cryptographic-asset" + }, + { + "bom-ref": "dummy-CP:SIGNATURE", + "cryptoProperties": { + "algorithmProperties": { + "primitive": "signature" + }, + "assetType": "algorithm" + }, + "name": "CryptoPrimitive: SIGNATURE", + "type": "cryptographic-asset" + }, + { + "bom-ref": "dummy-CP:STREAM_CIPHER", + "cryptoProperties": { + "algorithmProperties": { + "primitive": "stream-cipher" + }, + "assetType": "algorithm" + }, + "name": "CryptoPrimitive: STREAM_CIPHER", + "type": "cryptographic-asset" + }, + { + "bom-ref": "dummy-CP:UNKNOWN", + "cryptoProperties": { + "algorithmProperties": { + "primitive": "unknown" + }, + "assetType": "algorithm" + }, + "name": "CryptoPrimitive: UNKNOWN", + "type": "cryptographic-asset" + }, + { + "bom-ref": "dummy-CP:XOF", + "cryptoProperties": { + "algorithmProperties": { + "primitive": "xof" + }, + "assetType": "algorithm" + }, + "name": "CryptoPrimitive: XOF", + "type": "cryptographic-asset" + } + ], + "dependencies": [ + { + "ref": "dummy-CP:AE" + }, + { + "ref": "dummy-CP:BLOCK_CIPHER" + }, + { + "ref": "dummy-CP:COMBINER" + }, + { + "ref": "dummy-CP:DRBG" + }, + { + "ref": "dummy-CP:HASH" + }, + { + "ref": "dummy-CP:KDF" + }, + { + "ref": "dummy-CP:KEM" + }, + { + "ref": "dummy-CP:KEY_AGREE" + }, + { + "ref": "dummy-CP:MAC" + }, + { + "ref": "dummy-CP:OTHER" + }, + { + "ref": "dummy-CP:PKE" + }, + { + "ref": "dummy-CP:SIGNATURE" + }, + { + "ref": "dummy-CP:STREAM_CIPHER" + }, + { + "ref": "dummy-CP:UNKNOWN" + }, + { + "ref": "dummy-CP:XOF" + } + ], + "metadata": { + "timestamp": "2023-01-07T13:44:32.312678+00:00" + }, + "properties": [ + { + "name": "key1", + "value": "val1" + }, + { + "name": "key2", + "value": "val2" + } + ], + "serialNumber": "urn:uuid:1441d33a-e0fc-45b5-af3b-61ee52a88bac", + "version": 1, + "$schema": "http://cyclonedx.org/schema/bom-1.7.schema.json", + "bomFormat": "CycloneDX", + "specVersion": "1.7" +} \ No newline at end of file diff --git a/tests/_data/snapshots/enum_CryptoPrimitive-1.7.xml.bin b/tests/_data/snapshots/enum_CryptoPrimitive-1.7.xml.bin new file mode 100644 index 000000000..5e5591c99 --- /dev/null +++ b/tests/_data/snapshots/enum_CryptoPrimitive-1.7.xml.bin @@ -0,0 +1,164 @@ + + + + 2023-01-07T13:44:32.312678+00:00 + + + + CryptoPrimitive: AE + + algorithm + + ae + + + + + CryptoPrimitive: BLOCK_CIPHER + + algorithm + + block-cipher + + + + + CryptoPrimitive: COMBINER + + algorithm + + combiner + + + + + CryptoPrimitive: DRBG + + algorithm + + drbg + + + + + CryptoPrimitive: HASH + + algorithm + + hash + + + + + CryptoPrimitive: KDF + + algorithm + + kdf + + + + + CryptoPrimitive: KEM + + algorithm + + kem + + + + + CryptoPrimitive: KEY_AGREE + + algorithm + + key-agree + + + + + CryptoPrimitive: MAC + + algorithm + + mac + + + + + CryptoPrimitive: OTHER + + algorithm + + other + + + + + CryptoPrimitive: PKE + + algorithm + + pke + + + + + CryptoPrimitive: SIGNATURE + + algorithm + + signature + + + + + CryptoPrimitive: STREAM_CIPHER + + algorithm + + stream-cipher + + + + + CryptoPrimitive: UNKNOWN + + algorithm + + unknown + + + + + CryptoPrimitive: XOF + + algorithm + + xof + + + + + + + + + + + + + + + + + + + + + + + val1 + val2 + + From 1860d13a5b19e4a8d055f6ccc3ea007bffd6737b Mon Sep 17 00:00:00 2001 From: Jan Kowalleck Date: Mon, 15 Jun 2026 11:43:18 +0200 Subject: [PATCH 15/19] tests: enum CryptoExecutionEnvironment Signed-off-by: Jan Kowalleck --- cyclonedx/model/crypto.py | 2 + ...um_CryptoExecutionEnvironment-1.6.json.bin | 108 ++++++++++++++++++ ...num_CryptoExecutionEnvironment-1.6.xml.bin | 74 ++++++++++++ ...um_CryptoExecutionEnvironment-1.7.json.bin | 108 ++++++++++++++++++ ...num_CryptoExecutionEnvironment-1.7.xml.bin | 74 ++++++++++++ tests/test_enums.py | 29 ++++- 6 files changed, 394 insertions(+), 1 deletion(-) create mode 100644 tests/_data/snapshots/enum_CryptoExecutionEnvironment-1.6.json.bin create mode 100644 tests/_data/snapshots/enum_CryptoExecutionEnvironment-1.6.xml.bin create mode 100644 tests/_data/snapshots/enum_CryptoExecutionEnvironment-1.7.json.bin create mode 100644 tests/_data/snapshots/enum_CryptoExecutionEnvironment-1.7.xml.bin diff --git a/cyclonedx/model/crypto.py b/cyclonedx/model/crypto.py index 37122e113..746a6deec 100644 --- a/cyclonedx/model/crypto.py +++ b/cyclonedx/model/crypto.py @@ -93,6 +93,8 @@ class CryptoPrimitive(str, Enum): @serializable.serializable_enum class CryptoExecutionEnvironment(str, Enum): + # TODO: rename to `CryptoAlgorithmExecutionEnvironment` + """ This is our internal representation of the cryptoPropertiesType.algorithmProperties.executionEnvironment ENUM type within the CycloneDX standard. diff --git a/tests/_data/snapshots/enum_CryptoExecutionEnvironment-1.6.json.bin b/tests/_data/snapshots/enum_CryptoExecutionEnvironment-1.6.json.bin new file mode 100644 index 000000000..e1cab98b0 --- /dev/null +++ b/tests/_data/snapshots/enum_CryptoExecutionEnvironment-1.6.json.bin @@ -0,0 +1,108 @@ +{ + "components": [ + { + "bom-ref": "dummy-CEE:HARDWARE", + "cryptoProperties": { + "algorithmProperties": { + "executionEnvironment": "hardware" + }, + "assetType": "algorithm" + }, + "name": "CryptoExecutionEnvironment: HARDWARE", + "type": "cryptographic-asset" + }, + { + "bom-ref": "dummy-CEE:OTHER", + "cryptoProperties": { + "algorithmProperties": { + "executionEnvironment": "other" + }, + "assetType": "algorithm" + }, + "name": "CryptoExecutionEnvironment: OTHER", + "type": "cryptographic-asset" + }, + { + "bom-ref": "dummy-CEE:SOFTWARE_ENCRYPTED_RAM", + "cryptoProperties": { + "algorithmProperties": { + "executionEnvironment": "software-encrypted-ram" + }, + "assetType": "algorithm" + }, + "name": "CryptoExecutionEnvironment: SOFTWARE_ENCRYPTED_RAM", + "type": "cryptographic-asset" + }, + { + "bom-ref": "dummy-CEE:SOFTWARE_PLAIN_RAM", + "cryptoProperties": { + "algorithmProperties": { + "executionEnvironment": "software-plain-ram" + }, + "assetType": "algorithm" + }, + "name": "CryptoExecutionEnvironment: SOFTWARE_PLAIN_RAM", + "type": "cryptographic-asset" + }, + { + "bom-ref": "dummy-CEE:SOFTWARE_TEE", + "cryptoProperties": { + "algorithmProperties": { + "executionEnvironment": "software-tee" + }, + "assetType": "algorithm" + }, + "name": "CryptoExecutionEnvironment: SOFTWARE_TEE", + "type": "cryptographic-asset" + }, + { + "bom-ref": "dummy-CEE:UNKNOWN", + "cryptoProperties": { + "algorithmProperties": { + "executionEnvironment": "unknown" + }, + "assetType": "algorithm" + }, + "name": "CryptoExecutionEnvironment: UNKNOWN", + "type": "cryptographic-asset" + } + ], + "dependencies": [ + { + "ref": "dummy-CEE:HARDWARE" + }, + { + "ref": "dummy-CEE:OTHER" + }, + { + "ref": "dummy-CEE:SOFTWARE_ENCRYPTED_RAM" + }, + { + "ref": "dummy-CEE:SOFTWARE_PLAIN_RAM" + }, + { + "ref": "dummy-CEE:SOFTWARE_TEE" + }, + { + "ref": "dummy-CEE:UNKNOWN" + } + ], + "metadata": { + "timestamp": "2023-01-07T13:44:32.312678+00:00" + }, + "properties": [ + { + "name": "key1", + "value": "val1" + }, + { + "name": "key2", + "value": "val2" + } + ], + "serialNumber": "urn:uuid:1441d33a-e0fc-45b5-af3b-61ee52a88bac", + "version": 1, + "$schema": "http://cyclonedx.org/schema/bom-1.6.schema.json", + "bomFormat": "CycloneDX", + "specVersion": "1.6" +} \ No newline at end of file diff --git a/tests/_data/snapshots/enum_CryptoExecutionEnvironment-1.6.xml.bin b/tests/_data/snapshots/enum_CryptoExecutionEnvironment-1.6.xml.bin new file mode 100644 index 000000000..f45d314ab --- /dev/null +++ b/tests/_data/snapshots/enum_CryptoExecutionEnvironment-1.6.xml.bin @@ -0,0 +1,74 @@ + + + + 2023-01-07T13:44:32.312678+00:00 + + + + CryptoExecutionEnvironment: HARDWARE + + algorithm + + hardware + + + + + CryptoExecutionEnvironment: OTHER + + algorithm + + other + + + + + CryptoExecutionEnvironment: SOFTWARE_ENCRYPTED_RAM + + algorithm + + software-encrypted-ram + + + + + CryptoExecutionEnvironment: SOFTWARE_PLAIN_RAM + + algorithm + + software-plain-ram + + + + + CryptoExecutionEnvironment: SOFTWARE_TEE + + algorithm + + software-tee + + + + + CryptoExecutionEnvironment: UNKNOWN + + algorithm + + unknown + + + + + + + + + + + + + + val1 + val2 + + diff --git a/tests/_data/snapshots/enum_CryptoExecutionEnvironment-1.7.json.bin b/tests/_data/snapshots/enum_CryptoExecutionEnvironment-1.7.json.bin new file mode 100644 index 000000000..3d6c2e608 --- /dev/null +++ b/tests/_data/snapshots/enum_CryptoExecutionEnvironment-1.7.json.bin @@ -0,0 +1,108 @@ +{ + "components": [ + { + "bom-ref": "dummy-CEE:HARDWARE", + "cryptoProperties": { + "algorithmProperties": { + "executionEnvironment": "hardware" + }, + "assetType": "algorithm" + }, + "name": "CryptoExecutionEnvironment: HARDWARE", + "type": "cryptographic-asset" + }, + { + "bom-ref": "dummy-CEE:OTHER", + "cryptoProperties": { + "algorithmProperties": { + "executionEnvironment": "other" + }, + "assetType": "algorithm" + }, + "name": "CryptoExecutionEnvironment: OTHER", + "type": "cryptographic-asset" + }, + { + "bom-ref": "dummy-CEE:SOFTWARE_ENCRYPTED_RAM", + "cryptoProperties": { + "algorithmProperties": { + "executionEnvironment": "software-encrypted-ram" + }, + "assetType": "algorithm" + }, + "name": "CryptoExecutionEnvironment: SOFTWARE_ENCRYPTED_RAM", + "type": "cryptographic-asset" + }, + { + "bom-ref": "dummy-CEE:SOFTWARE_PLAIN_RAM", + "cryptoProperties": { + "algorithmProperties": { + "executionEnvironment": "software-plain-ram" + }, + "assetType": "algorithm" + }, + "name": "CryptoExecutionEnvironment: SOFTWARE_PLAIN_RAM", + "type": "cryptographic-asset" + }, + { + "bom-ref": "dummy-CEE:SOFTWARE_TEE", + "cryptoProperties": { + "algorithmProperties": { + "executionEnvironment": "software-tee" + }, + "assetType": "algorithm" + }, + "name": "CryptoExecutionEnvironment: SOFTWARE_TEE", + "type": "cryptographic-asset" + }, + { + "bom-ref": "dummy-CEE:UNKNOWN", + "cryptoProperties": { + "algorithmProperties": { + "executionEnvironment": "unknown" + }, + "assetType": "algorithm" + }, + "name": "CryptoExecutionEnvironment: UNKNOWN", + "type": "cryptographic-asset" + } + ], + "dependencies": [ + { + "ref": "dummy-CEE:HARDWARE" + }, + { + "ref": "dummy-CEE:OTHER" + }, + { + "ref": "dummy-CEE:SOFTWARE_ENCRYPTED_RAM" + }, + { + "ref": "dummy-CEE:SOFTWARE_PLAIN_RAM" + }, + { + "ref": "dummy-CEE:SOFTWARE_TEE" + }, + { + "ref": "dummy-CEE:UNKNOWN" + } + ], + "metadata": { + "timestamp": "2023-01-07T13:44:32.312678+00:00" + }, + "properties": [ + { + "name": "key1", + "value": "val1" + }, + { + "name": "key2", + "value": "val2" + } + ], + "serialNumber": "urn:uuid:1441d33a-e0fc-45b5-af3b-61ee52a88bac", + "version": 1, + "$schema": "http://cyclonedx.org/schema/bom-1.7.schema.json", + "bomFormat": "CycloneDX", + "specVersion": "1.7" +} \ No newline at end of file diff --git a/tests/_data/snapshots/enum_CryptoExecutionEnvironment-1.7.xml.bin b/tests/_data/snapshots/enum_CryptoExecutionEnvironment-1.7.xml.bin new file mode 100644 index 000000000..fb95914ff --- /dev/null +++ b/tests/_data/snapshots/enum_CryptoExecutionEnvironment-1.7.xml.bin @@ -0,0 +1,74 @@ + + + + 2023-01-07T13:44:32.312678+00:00 + + + + CryptoExecutionEnvironment: HARDWARE + + algorithm + + hardware + + + + + CryptoExecutionEnvironment: OTHER + + algorithm + + other + + + + + CryptoExecutionEnvironment: SOFTWARE_ENCRYPTED_RAM + + algorithm + + software-encrypted-ram + + + + + CryptoExecutionEnvironment: SOFTWARE_PLAIN_RAM + + algorithm + + software-plain-ram + + + + + CryptoExecutionEnvironment: SOFTWARE_TEE + + algorithm + + software-tee + + + + + CryptoExecutionEnvironment: UNKNOWN + + algorithm + + unknown + + + + + + + + + + + + + + val1 + val2 + + diff --git a/tests/test_enums.py b/tests/test_enums.py index 25aec1e0d..2616688ba 100644 --- a/tests/test_enums.py +++ b/tests/test_enums.py @@ -674,6 +674,34 @@ def test_cases_render_valid(self, of: OutputFormat, sv: SchemaVersion, *_: Any, super()._test_cases_render(bom, of, sv) +@ddt +class TestEnumCryptoExecutionEnvironment(_EnumTestCase): + + @idata(set(chain( + dp_cases_from_xml_schemas(f"./{SCHEMA_NS}complexType[@name='cryptoPropertiesType']/{SCHEMA_NS}sequence/{SCHEMA_NS}element[@name='algorithmProperties']/{SCHEMA_NS}complexType/{SCHEMA_NS}sequence/{SCHEMA_NS}element[@name='executionEnvironment']/{SCHEMA_NS}simpleType"), + dp_cases_from_json_schemas('definitions', 'cryptoProperties', 'properties', 'algorithmProperties', 'properties', 'executionEnvironment'), + ))) + def test_knows_value(self, value: str) -> None: + super()._test_knows_value(CryptoExecutionEnvironment, value) + + @named_data(*(d for d in NAMED_OF_SV if d[2] >= SchemaVersion.V1_6 )) + def test_cases_render_valid(self, of: OutputFormat, sv: SchemaVersion, *_: Any, **__: Any) -> None: + bom = _make_bom( + components=[ + Component( + name=f'CryptoExecutionEnvironment: {cee.name}', bom_ref=f'dummy-CEE:{cee.name}', + type=ComponentType.CRYPTOGRAPHIC_ASSET, + crypto_properties=CryptoProperties( + asset_type=CryptoAssetType.ALGORITHM, + algorithm_properties=AlgorithmProperties( + execution_environment=cee + ) + ) + ) for cee in CryptoExecutionEnvironment + ]) + super()._test_cases_render(bom, of, sv) + + """ @ddt class TestEnum...(_EnumTestCase): @@ -697,7 +725,6 @@ def test_cases_render_valid(self, of: OutputFormat, sv: SchemaVersion, *_: Any, """ missing: -- CryptoExecutionEnvironment - CryptoImplementationPlatform - CryptoCertificationLevel - CryptoMode From e70a29fc9913afc386121d1c9802ce914839dd1f Mon Sep 17 00:00:00 2001 From: Jan Kowalleck Date: Mon, 15 Jun 2026 11:50:26 +0200 Subject: [PATCH 16/19] tests: enum CryptoImplementationPlatform Signed-off-by: Jan Kowalleck --- cyclonedx/model/crypto.py | 2 + ..._CryptoImplementationPlatform-1.6.json.bin | 220 ++++++++++++++++++ ...m_CryptoImplementationPlatform-1.6.xml.bin | 154 ++++++++++++ ..._CryptoImplementationPlatform-1.7.json.bin | 220 ++++++++++++++++++ ...m_CryptoImplementationPlatform-1.7.xml.bin | 154 ++++++++++++ tests/test_enums.py | 31 ++- 6 files changed, 780 insertions(+), 1 deletion(-) create mode 100644 tests/_data/snapshots/enum_CryptoImplementationPlatform-1.6.json.bin create mode 100644 tests/_data/snapshots/enum_CryptoImplementationPlatform-1.6.xml.bin create mode 100644 tests/_data/snapshots/enum_CryptoImplementationPlatform-1.7.json.bin create mode 100644 tests/_data/snapshots/enum_CryptoImplementationPlatform-1.7.xml.bin diff --git a/cyclonedx/model/crypto.py b/cyclonedx/model/crypto.py index 746a6deec..928e9f57a 100644 --- a/cyclonedx/model/crypto.py +++ b/cyclonedx/model/crypto.py @@ -117,6 +117,8 @@ class CryptoExecutionEnvironment(str, Enum): @serializable.serializable_enum class CryptoImplementationPlatform(str, Enum): + # TODO: rename to `CryptoAlgorithmImplementationPlatform` + """ This is our internal representation of the cryptoPropertiesType.algorithmProperties.implementationPlatform ENUM type within the CycloneDX standard. diff --git a/tests/_data/snapshots/enum_CryptoImplementationPlatform-1.6.json.bin b/tests/_data/snapshots/enum_CryptoImplementationPlatform-1.6.json.bin new file mode 100644 index 000000000..280d02b19 --- /dev/null +++ b/tests/_data/snapshots/enum_CryptoImplementationPlatform-1.6.json.bin @@ -0,0 +1,220 @@ +{ + "components": [ + { + "bom-ref": "dummy-CIP:ARMV7_A", + "cryptoProperties": { + "algorithmProperties": { + "implementationPlatform": "armv7-a" + }, + "assetType": "algorithm" + }, + "name": "CryptoImplementationPlatform: ARMV7_A", + "type": "cryptographic-asset" + }, + { + "bom-ref": "dummy-CIP:ARMV7_M", + "cryptoProperties": { + "algorithmProperties": { + "implementationPlatform": "armv7-m" + }, + "assetType": "algorithm" + }, + "name": "CryptoImplementationPlatform: ARMV7_M", + "type": "cryptographic-asset" + }, + { + "bom-ref": "dummy-CIP:ARMV8_A", + "cryptoProperties": { + "algorithmProperties": { + "implementationPlatform": "armv8-a" + }, + "assetType": "algorithm" + }, + "name": "CryptoImplementationPlatform: ARMV8_A", + "type": "cryptographic-asset" + }, + { + "bom-ref": "dummy-CIP:ARMV8_M", + "cryptoProperties": { + "algorithmProperties": { + "implementationPlatform": "armv8-m" + }, + "assetType": "algorithm" + }, + "name": "CryptoImplementationPlatform: ARMV8_M", + "type": "cryptographic-asset" + }, + { + "bom-ref": "dummy-CIP:ARMV9_A", + "cryptoProperties": { + "algorithmProperties": { + "implementationPlatform": "armv9-a" + }, + "assetType": "algorithm" + }, + "name": "CryptoImplementationPlatform: ARMV9_A", + "type": "cryptographic-asset" + }, + { + "bom-ref": "dummy-CIP:ARMV9_M", + "cryptoProperties": { + "algorithmProperties": { + "implementationPlatform": "armv9-m" + }, + "assetType": "algorithm" + }, + "name": "CryptoImplementationPlatform: ARMV9_M", + "type": "cryptographic-asset" + }, + { + "bom-ref": "dummy-CIP:GENERIC", + "cryptoProperties": { + "algorithmProperties": { + "implementationPlatform": "generic" + }, + "assetType": "algorithm" + }, + "name": "CryptoImplementationPlatform: GENERIC", + "type": "cryptographic-asset" + }, + { + "bom-ref": "dummy-CIP:OTHER", + "cryptoProperties": { + "algorithmProperties": { + "implementationPlatform": "other" + }, + "assetType": "algorithm" + }, + "name": "CryptoImplementationPlatform: OTHER", + "type": "cryptographic-asset" + }, + { + "bom-ref": "dummy-CIP:PPC64", + "cryptoProperties": { + "algorithmProperties": { + "implementationPlatform": "ppc64" + }, + "assetType": "algorithm" + }, + "name": "CryptoImplementationPlatform: PPC64", + "type": "cryptographic-asset" + }, + { + "bom-ref": "dummy-CIP:PPC64LE", + "cryptoProperties": { + "algorithmProperties": { + "implementationPlatform": "ppc64le" + }, + "assetType": "algorithm" + }, + "name": "CryptoImplementationPlatform: PPC64LE", + "type": "cryptographic-asset" + }, + { + "bom-ref": "dummy-CIP:S390X", + "cryptoProperties": { + "algorithmProperties": { + "implementationPlatform": "s390x" + }, + "assetType": "algorithm" + }, + "name": "CryptoImplementationPlatform: S390X", + "type": "cryptographic-asset" + }, + { + "bom-ref": "dummy-CIP:UNKNOWN", + "cryptoProperties": { + "algorithmProperties": { + "implementationPlatform": "unknown" + }, + "assetType": "algorithm" + }, + "name": "CryptoImplementationPlatform: UNKNOWN", + "type": "cryptographic-asset" + }, + { + "bom-ref": "dummy-CIP:X86_32", + "cryptoProperties": { + "algorithmProperties": { + "implementationPlatform": "x86_32" + }, + "assetType": "algorithm" + }, + "name": "CryptoImplementationPlatform: X86_32", + "type": "cryptographic-asset" + }, + { + "bom-ref": "dummy-CIP:X86_64", + "cryptoProperties": { + "algorithmProperties": { + "implementationPlatform": "x86_64" + }, + "assetType": "algorithm" + }, + "name": "CryptoImplementationPlatform: X86_64", + "type": "cryptographic-asset" + } + ], + "dependencies": [ + { + "ref": "dummy-CIP:ARMV7_A" + }, + { + "ref": "dummy-CIP:ARMV7_M" + }, + { + "ref": "dummy-CIP:ARMV8_A" + }, + { + "ref": "dummy-CIP:ARMV8_M" + }, + { + "ref": "dummy-CIP:ARMV9_A" + }, + { + "ref": "dummy-CIP:ARMV9_M" + }, + { + "ref": "dummy-CIP:GENERIC" + }, + { + "ref": "dummy-CIP:OTHER" + }, + { + "ref": "dummy-CIP:PPC64" + }, + { + "ref": "dummy-CIP:PPC64LE" + }, + { + "ref": "dummy-CIP:S390X" + }, + { + "ref": "dummy-CIP:UNKNOWN" + }, + { + "ref": "dummy-CIP:X86_32" + }, + { + "ref": "dummy-CIP:X86_64" + } + ], + "metadata": { + "timestamp": "2023-01-07T13:44:32.312678+00:00" + }, + "properties": [ + { + "name": "key1", + "value": "val1" + }, + { + "name": "key2", + "value": "val2" + } + ], + "serialNumber": "urn:uuid:1441d33a-e0fc-45b5-af3b-61ee52a88bac", + "version": 1, + "$schema": "http://cyclonedx.org/schema/bom-1.6.schema.json", + "bomFormat": "CycloneDX", + "specVersion": "1.6" +} \ No newline at end of file diff --git a/tests/_data/snapshots/enum_CryptoImplementationPlatform-1.6.xml.bin b/tests/_data/snapshots/enum_CryptoImplementationPlatform-1.6.xml.bin new file mode 100644 index 000000000..ab0c204ec --- /dev/null +++ b/tests/_data/snapshots/enum_CryptoImplementationPlatform-1.6.xml.bin @@ -0,0 +1,154 @@ + + + + 2023-01-07T13:44:32.312678+00:00 + + + + CryptoImplementationPlatform: ARMV7_A + + algorithm + + armv7-a + + + + + CryptoImplementationPlatform: ARMV7_M + + algorithm + + armv7-m + + + + + CryptoImplementationPlatform: ARMV8_A + + algorithm + + armv8-a + + + + + CryptoImplementationPlatform: ARMV8_M + + algorithm + + armv8-m + + + + + CryptoImplementationPlatform: ARMV9_A + + algorithm + + armv9-a + + + + + CryptoImplementationPlatform: ARMV9_M + + algorithm + + armv9-m + + + + + CryptoImplementationPlatform: GENERIC + + algorithm + + generic + + + + + CryptoImplementationPlatform: OTHER + + algorithm + + other + + + + + CryptoImplementationPlatform: PPC64 + + algorithm + + ppc64 + + + + + CryptoImplementationPlatform: PPC64LE + + algorithm + + ppc64le + + + + + CryptoImplementationPlatform: S390X + + algorithm + + s390x + + + + + CryptoImplementationPlatform: UNKNOWN + + algorithm + + unknown + + + + + CryptoImplementationPlatform: X86_32 + + algorithm + + x86_32 + + + + + CryptoImplementationPlatform: X86_64 + + algorithm + + x86_64 + + + + + + + + + + + + + + + + + + + + + + val1 + val2 + + diff --git a/tests/_data/snapshots/enum_CryptoImplementationPlatform-1.7.json.bin b/tests/_data/snapshots/enum_CryptoImplementationPlatform-1.7.json.bin new file mode 100644 index 000000000..d3d88155f --- /dev/null +++ b/tests/_data/snapshots/enum_CryptoImplementationPlatform-1.7.json.bin @@ -0,0 +1,220 @@ +{ + "components": [ + { + "bom-ref": "dummy-CIP:ARMV7_A", + "cryptoProperties": { + "algorithmProperties": { + "implementationPlatform": "armv7-a" + }, + "assetType": "algorithm" + }, + "name": "CryptoImplementationPlatform: ARMV7_A", + "type": "cryptographic-asset" + }, + { + "bom-ref": "dummy-CIP:ARMV7_M", + "cryptoProperties": { + "algorithmProperties": { + "implementationPlatform": "armv7-m" + }, + "assetType": "algorithm" + }, + "name": "CryptoImplementationPlatform: ARMV7_M", + "type": "cryptographic-asset" + }, + { + "bom-ref": "dummy-CIP:ARMV8_A", + "cryptoProperties": { + "algorithmProperties": { + "implementationPlatform": "armv8-a" + }, + "assetType": "algorithm" + }, + "name": "CryptoImplementationPlatform: ARMV8_A", + "type": "cryptographic-asset" + }, + { + "bom-ref": "dummy-CIP:ARMV8_M", + "cryptoProperties": { + "algorithmProperties": { + "implementationPlatform": "armv8-m" + }, + "assetType": "algorithm" + }, + "name": "CryptoImplementationPlatform: ARMV8_M", + "type": "cryptographic-asset" + }, + { + "bom-ref": "dummy-CIP:ARMV9_A", + "cryptoProperties": { + "algorithmProperties": { + "implementationPlatform": "armv9-a" + }, + "assetType": "algorithm" + }, + "name": "CryptoImplementationPlatform: ARMV9_A", + "type": "cryptographic-asset" + }, + { + "bom-ref": "dummy-CIP:ARMV9_M", + "cryptoProperties": { + "algorithmProperties": { + "implementationPlatform": "armv9-m" + }, + "assetType": "algorithm" + }, + "name": "CryptoImplementationPlatform: ARMV9_M", + "type": "cryptographic-asset" + }, + { + "bom-ref": "dummy-CIP:GENERIC", + "cryptoProperties": { + "algorithmProperties": { + "implementationPlatform": "generic" + }, + "assetType": "algorithm" + }, + "name": "CryptoImplementationPlatform: GENERIC", + "type": "cryptographic-asset" + }, + { + "bom-ref": "dummy-CIP:OTHER", + "cryptoProperties": { + "algorithmProperties": { + "implementationPlatform": "other" + }, + "assetType": "algorithm" + }, + "name": "CryptoImplementationPlatform: OTHER", + "type": "cryptographic-asset" + }, + { + "bom-ref": "dummy-CIP:PPC64", + "cryptoProperties": { + "algorithmProperties": { + "implementationPlatform": "ppc64" + }, + "assetType": "algorithm" + }, + "name": "CryptoImplementationPlatform: PPC64", + "type": "cryptographic-asset" + }, + { + "bom-ref": "dummy-CIP:PPC64LE", + "cryptoProperties": { + "algorithmProperties": { + "implementationPlatform": "ppc64le" + }, + "assetType": "algorithm" + }, + "name": "CryptoImplementationPlatform: PPC64LE", + "type": "cryptographic-asset" + }, + { + "bom-ref": "dummy-CIP:S390X", + "cryptoProperties": { + "algorithmProperties": { + "implementationPlatform": "s390x" + }, + "assetType": "algorithm" + }, + "name": "CryptoImplementationPlatform: S390X", + "type": "cryptographic-asset" + }, + { + "bom-ref": "dummy-CIP:UNKNOWN", + "cryptoProperties": { + "algorithmProperties": { + "implementationPlatform": "unknown" + }, + "assetType": "algorithm" + }, + "name": "CryptoImplementationPlatform: UNKNOWN", + "type": "cryptographic-asset" + }, + { + "bom-ref": "dummy-CIP:X86_32", + "cryptoProperties": { + "algorithmProperties": { + "implementationPlatform": "x86_32" + }, + "assetType": "algorithm" + }, + "name": "CryptoImplementationPlatform: X86_32", + "type": "cryptographic-asset" + }, + { + "bom-ref": "dummy-CIP:X86_64", + "cryptoProperties": { + "algorithmProperties": { + "implementationPlatform": "x86_64" + }, + "assetType": "algorithm" + }, + "name": "CryptoImplementationPlatform: X86_64", + "type": "cryptographic-asset" + } + ], + "dependencies": [ + { + "ref": "dummy-CIP:ARMV7_A" + }, + { + "ref": "dummy-CIP:ARMV7_M" + }, + { + "ref": "dummy-CIP:ARMV8_A" + }, + { + "ref": "dummy-CIP:ARMV8_M" + }, + { + "ref": "dummy-CIP:ARMV9_A" + }, + { + "ref": "dummy-CIP:ARMV9_M" + }, + { + "ref": "dummy-CIP:GENERIC" + }, + { + "ref": "dummy-CIP:OTHER" + }, + { + "ref": "dummy-CIP:PPC64" + }, + { + "ref": "dummy-CIP:PPC64LE" + }, + { + "ref": "dummy-CIP:S390X" + }, + { + "ref": "dummy-CIP:UNKNOWN" + }, + { + "ref": "dummy-CIP:X86_32" + }, + { + "ref": "dummy-CIP:X86_64" + } + ], + "metadata": { + "timestamp": "2023-01-07T13:44:32.312678+00:00" + }, + "properties": [ + { + "name": "key1", + "value": "val1" + }, + { + "name": "key2", + "value": "val2" + } + ], + "serialNumber": "urn:uuid:1441d33a-e0fc-45b5-af3b-61ee52a88bac", + "version": 1, + "$schema": "http://cyclonedx.org/schema/bom-1.7.schema.json", + "bomFormat": "CycloneDX", + "specVersion": "1.7" +} \ No newline at end of file diff --git a/tests/_data/snapshots/enum_CryptoImplementationPlatform-1.7.xml.bin b/tests/_data/snapshots/enum_CryptoImplementationPlatform-1.7.xml.bin new file mode 100644 index 000000000..91b0c9a0b --- /dev/null +++ b/tests/_data/snapshots/enum_CryptoImplementationPlatform-1.7.xml.bin @@ -0,0 +1,154 @@ + + + + 2023-01-07T13:44:32.312678+00:00 + + + + CryptoImplementationPlatform: ARMV7_A + + algorithm + + armv7-a + + + + + CryptoImplementationPlatform: ARMV7_M + + algorithm + + armv7-m + + + + + CryptoImplementationPlatform: ARMV8_A + + algorithm + + armv8-a + + + + + CryptoImplementationPlatform: ARMV8_M + + algorithm + + armv8-m + + + + + CryptoImplementationPlatform: ARMV9_A + + algorithm + + armv9-a + + + + + CryptoImplementationPlatform: ARMV9_M + + algorithm + + armv9-m + + + + + CryptoImplementationPlatform: GENERIC + + algorithm + + generic + + + + + CryptoImplementationPlatform: OTHER + + algorithm + + other + + + + + CryptoImplementationPlatform: PPC64 + + algorithm + + ppc64 + + + + + CryptoImplementationPlatform: PPC64LE + + algorithm + + ppc64le + + + + + CryptoImplementationPlatform: S390X + + algorithm + + s390x + + + + + CryptoImplementationPlatform: UNKNOWN + + algorithm + + unknown + + + + + CryptoImplementationPlatform: X86_32 + + algorithm + + x86_32 + + + + + CryptoImplementationPlatform: X86_64 + + algorithm + + x86_64 + + + + + + + + + + + + + + + + + + + + + + val1 + val2 + + diff --git a/tests/test_enums.py b/tests/test_enums.py index 2616688ba..a92b05c05 100644 --- a/tests/test_enums.py +++ b/tests/test_enums.py @@ -702,6 +702,36 @@ def test_cases_render_valid(self, of: OutputFormat, sv: SchemaVersion, *_: Any, super()._test_cases_render(bom, of, sv) + +@ddt +class TestEnumCryptoImplementationPlatform (_EnumTestCase): + + @idata(set(chain( + dp_cases_from_xml_schemas(f"./{SCHEMA_NS}complexType[@name='cryptoPropertiesType']/{SCHEMA_NS}sequence/{SCHEMA_NS}element[@name='algorithmProperties']/{SCHEMA_NS}complexType/{SCHEMA_NS}sequence/{SCHEMA_NS}element[@name='implementationPlatform']/{SCHEMA_NS}simpleType"), + dp_cases_from_json_schemas('definitions', 'cryptoProperties', 'properties', 'algorithmProperties', 'properties', 'implementationPlatform'), + ))) + def test_knows_value(self, value: str) -> None: + super()._test_knows_value(CryptoImplementationPlatform, value) + + @named_data(*(d for d in NAMED_OF_SV if d[2] >= SchemaVersion.V1_6 )) + def test_cases_render_valid(self, of: OutputFormat, sv: SchemaVersion, *_: Any, **__: Any) -> None: + bom = _make_bom( + components=[ + Component( + name=f'CryptoImplementationPlatform: {cip.name}', bom_ref=f'dummy-CIP:{cip.name}', + type=ComponentType.CRYPTOGRAPHIC_ASSET, + crypto_properties=CryptoProperties( + asset_type=CryptoAssetType.ALGORITHM, + algorithm_properties=AlgorithmProperties( + implementation_platform=cip + ) + ) + ) for cip in CryptoImplementationPlatform + ]) + super()._test_cases_render(bom, of, sv) + + + """ @ddt class TestEnum...(_EnumTestCase): @@ -725,7 +755,6 @@ def test_cases_render_valid(self, of: OutputFormat, sv: SchemaVersion, *_: Any, """ missing: -- CryptoImplementationPlatform - CryptoCertificationLevel - CryptoMode - CryptoPadding From d27a09713f32726c960db5726d85382f2c13851d Mon Sep 17 00:00:00 2001 From: Jan Kowalleck Date: Mon, 15 Jun 2026 12:08:25 +0200 Subject: [PATCH 17/19] tests: enum CryptoCertificationLevel Signed-off-by: Jan Kowalleck --- cyclonedx/model/crypto.py | 4 +- ...enum_CryptoCertificationLevel-1.6.json.bin | 488 ++++++++++++++++++ .../enum_CryptoCertificationLevel-1.6.xml.bin | 304 +++++++++++ ...enum_CryptoCertificationLevel-1.7.json.bin | 488 ++++++++++++++++++ .../enum_CryptoCertificationLevel-1.7.xml.bin | 304 +++++++++++ tests/test_enums.py | 29 +- 6 files changed, 1615 insertions(+), 2 deletions(-) create mode 100644 tests/_data/snapshots/enum_CryptoCertificationLevel-1.6.json.bin create mode 100644 tests/_data/snapshots/enum_CryptoCertificationLevel-1.6.xml.bin create mode 100644 tests/_data/snapshots/enum_CryptoCertificationLevel-1.7.json.bin create mode 100644 tests/_data/snapshots/enum_CryptoCertificationLevel-1.7.xml.bin diff --git a/cyclonedx/model/crypto.py b/cyclonedx/model/crypto.py index 928e9f57a..012975f2b 100644 --- a/cyclonedx/model/crypto.py +++ b/cyclonedx/model/crypto.py @@ -136,7 +136,7 @@ class CryptoImplementationPlatform(str, Enum): ARMV8_M = 'armv8-m' ARMV9_A = 'armv9-a' ARMV9_M = 'armv9-m' - GENERIC = 'generic' + GENERIC = 'generic' # TODO: move down PPC64 = 'ppc64' PPC64LE = 'ppc64le' S390X = 's390x' @@ -149,6 +149,8 @@ class CryptoImplementationPlatform(str, Enum): @serializable.serializable_enum class CryptoCertificationLevel(str, Enum): + # TODO: move to `CryptoAlgorithmCertificationLevel` + """ This is our internal representation of the cryptoPropertiesType.algorithmProperties.certificationLevel ENUM type within the CycloneDX standard. diff --git a/tests/_data/snapshots/enum_CryptoCertificationLevel-1.6.json.bin b/tests/_data/snapshots/enum_CryptoCertificationLevel-1.6.json.bin new file mode 100644 index 000000000..9256e7355 --- /dev/null +++ b/tests/_data/snapshots/enum_CryptoCertificationLevel-1.6.json.bin @@ -0,0 +1,488 @@ +{ + "components": [ + { + "bom-ref": "dummy-CIP:CC_EAL1", + "cryptoProperties": { + "algorithmProperties": { + "certificationLevel": [ + "cc-eal1" + ] + }, + "assetType": "algorithm" + }, + "name": "CryptoCertificationLevel: CC_EAL1", + "type": "cryptographic-asset" + }, + { + "bom-ref": "dummy-CIP:CC_EAL1_PLUS", + "cryptoProperties": { + "algorithmProperties": { + "certificationLevel": [ + "cc-eal1+" + ] + }, + "assetType": "algorithm" + }, + "name": "CryptoCertificationLevel: CC_EAL1_PLUS", + "type": "cryptographic-asset" + }, + { + "bom-ref": "dummy-CIP:CC_EAL2", + "cryptoProperties": { + "algorithmProperties": { + "certificationLevel": [ + "cc-eal2" + ] + }, + "assetType": "algorithm" + }, + "name": "CryptoCertificationLevel: CC_EAL2", + "type": "cryptographic-asset" + }, + { + "bom-ref": "dummy-CIP:CC_EAL2_PLUS", + "cryptoProperties": { + "algorithmProperties": { + "certificationLevel": [ + "cc-eal2+" + ] + }, + "assetType": "algorithm" + }, + "name": "CryptoCertificationLevel: CC_EAL2_PLUS", + "type": "cryptographic-asset" + }, + { + "bom-ref": "dummy-CIP:CC_EAL3", + "cryptoProperties": { + "algorithmProperties": { + "certificationLevel": [ + "cc-eal3" + ] + }, + "assetType": "algorithm" + }, + "name": "CryptoCertificationLevel: CC_EAL3", + "type": "cryptographic-asset" + }, + { + "bom-ref": "dummy-CIP:CC_EAL3_PLUS", + "cryptoProperties": { + "algorithmProperties": { + "certificationLevel": [ + "cc-eal3+" + ] + }, + "assetType": "algorithm" + }, + "name": "CryptoCertificationLevel: CC_EAL3_PLUS", + "type": "cryptographic-asset" + }, + { + "bom-ref": "dummy-CIP:CC_EAL4", + "cryptoProperties": { + "algorithmProperties": { + "certificationLevel": [ + "cc-eal4" + ] + }, + "assetType": "algorithm" + }, + "name": "CryptoCertificationLevel: CC_EAL4", + "type": "cryptographic-asset" + }, + { + "bom-ref": "dummy-CIP:CC_EAL4_PLUS", + "cryptoProperties": { + "algorithmProperties": { + "certificationLevel": [ + "cc-eal4+" + ] + }, + "assetType": "algorithm" + }, + "name": "CryptoCertificationLevel: CC_EAL4_PLUS", + "type": "cryptographic-asset" + }, + { + "bom-ref": "dummy-CIP:CC_EAL5", + "cryptoProperties": { + "algorithmProperties": { + "certificationLevel": [ + "cc-eal5" + ] + }, + "assetType": "algorithm" + }, + "name": "CryptoCertificationLevel: CC_EAL5", + "type": "cryptographic-asset" + }, + { + "bom-ref": "dummy-CIP:CC_EAL5_PLUS", + "cryptoProperties": { + "algorithmProperties": { + "certificationLevel": [ + "cc-eal5+" + ] + }, + "assetType": "algorithm" + }, + "name": "CryptoCertificationLevel: CC_EAL5_PLUS", + "type": "cryptographic-asset" + }, + { + "bom-ref": "dummy-CIP:CC_EAL6", + "cryptoProperties": { + "algorithmProperties": { + "certificationLevel": [ + "cc-eal6" + ] + }, + "assetType": "algorithm" + }, + "name": "CryptoCertificationLevel: CC_EAL6", + "type": "cryptographic-asset" + }, + { + "bom-ref": "dummy-CIP:CC_EAL6_PLUS", + "cryptoProperties": { + "algorithmProperties": { + "certificationLevel": [ + "cc-eal6+" + ] + }, + "assetType": "algorithm" + }, + "name": "CryptoCertificationLevel: CC_EAL6_PLUS", + "type": "cryptographic-asset" + }, + { + "bom-ref": "dummy-CIP:CC_EAL7", + "cryptoProperties": { + "algorithmProperties": { + "certificationLevel": [ + "cc-eal7" + ] + }, + "assetType": "algorithm" + }, + "name": "CryptoCertificationLevel: CC_EAL7", + "type": "cryptographic-asset" + }, + { + "bom-ref": "dummy-CIP:CC_EAL7_PLUS", + "cryptoProperties": { + "algorithmProperties": { + "certificationLevel": [ + "cc-eal7+" + ] + }, + "assetType": "algorithm" + }, + "name": "CryptoCertificationLevel: CC_EAL7_PLUS", + "type": "cryptographic-asset" + }, + { + "bom-ref": "dummy-CIP:FIPS140_1_L1", + "cryptoProperties": { + "algorithmProperties": { + "certificationLevel": [ + "fips140-1-l1" + ] + }, + "assetType": "algorithm" + }, + "name": "CryptoCertificationLevel: FIPS140_1_L1", + "type": "cryptographic-asset" + }, + { + "bom-ref": "dummy-CIP:FIPS140_1_L2", + "cryptoProperties": { + "algorithmProperties": { + "certificationLevel": [ + "fips140-1-l2" + ] + }, + "assetType": "algorithm" + }, + "name": "CryptoCertificationLevel: FIPS140_1_L2", + "type": "cryptographic-asset" + }, + { + "bom-ref": "dummy-CIP:FIPS140_1_L3", + "cryptoProperties": { + "algorithmProperties": { + "certificationLevel": [ + "fips140-1-l3" + ] + }, + "assetType": "algorithm" + }, + "name": "CryptoCertificationLevel: FIPS140_1_L3", + "type": "cryptographic-asset" + }, + { + "bom-ref": "dummy-CIP:FIPS140_1_L4", + "cryptoProperties": { + "algorithmProperties": { + "certificationLevel": [ + "fips140-1-l4" + ] + }, + "assetType": "algorithm" + }, + "name": "CryptoCertificationLevel: FIPS140_1_L4", + "type": "cryptographic-asset" + }, + { + "bom-ref": "dummy-CIP:FIPS140_2_L1", + "cryptoProperties": { + "algorithmProperties": { + "certificationLevel": [ + "fips140-2-l1" + ] + }, + "assetType": "algorithm" + }, + "name": "CryptoCertificationLevel: FIPS140_2_L1", + "type": "cryptographic-asset" + }, + { + "bom-ref": "dummy-CIP:FIPS140_2_L2", + "cryptoProperties": { + "algorithmProperties": { + "certificationLevel": [ + "fips140-2-l2" + ] + }, + "assetType": "algorithm" + }, + "name": "CryptoCertificationLevel: FIPS140_2_L2", + "type": "cryptographic-asset" + }, + { + "bom-ref": "dummy-CIP:FIPS140_2_L3", + "cryptoProperties": { + "algorithmProperties": { + "certificationLevel": [ + "fips140-2-l3" + ] + }, + "assetType": "algorithm" + }, + "name": "CryptoCertificationLevel: FIPS140_2_L3", + "type": "cryptographic-asset" + }, + { + "bom-ref": "dummy-CIP:FIPS140_2_L4", + "cryptoProperties": { + "algorithmProperties": { + "certificationLevel": [ + "fips140-2-l4" + ] + }, + "assetType": "algorithm" + }, + "name": "CryptoCertificationLevel: FIPS140_2_L4", + "type": "cryptographic-asset" + }, + { + "bom-ref": "dummy-CIP:FIPS140_3_L1", + "cryptoProperties": { + "algorithmProperties": { + "certificationLevel": [ + "fips140-3-l1" + ] + }, + "assetType": "algorithm" + }, + "name": "CryptoCertificationLevel: FIPS140_3_L1", + "type": "cryptographic-asset" + }, + { + "bom-ref": "dummy-CIP:FIPS140_3_L2", + "cryptoProperties": { + "algorithmProperties": { + "certificationLevel": [ + "fips140-3-l2" + ] + }, + "assetType": "algorithm" + }, + "name": "CryptoCertificationLevel: FIPS140_3_L2", + "type": "cryptographic-asset" + }, + { + "bom-ref": "dummy-CIP:FIPS140_3_L3", + "cryptoProperties": { + "algorithmProperties": { + "certificationLevel": [ + "fips140-3-l3" + ] + }, + "assetType": "algorithm" + }, + "name": "CryptoCertificationLevel: FIPS140_3_L3", + "type": "cryptographic-asset" + }, + { + "bom-ref": "dummy-CIP:FIPS140_3_L4", + "cryptoProperties": { + "algorithmProperties": { + "certificationLevel": [ + "fips140-3-l4" + ] + }, + "assetType": "algorithm" + }, + "name": "CryptoCertificationLevel: FIPS140_3_L4", + "type": "cryptographic-asset" + }, + { + "bom-ref": "dummy-CIP:NONE", + "cryptoProperties": { + "algorithmProperties": { + "certificationLevel": [ + "none" + ] + }, + "assetType": "algorithm" + }, + "name": "CryptoCertificationLevel: NONE", + "type": "cryptographic-asset" + }, + { + "bom-ref": "dummy-CIP:OTHER", + "cryptoProperties": { + "algorithmProperties": { + "certificationLevel": [ + "other" + ] + }, + "assetType": "algorithm" + }, + "name": "CryptoCertificationLevel: OTHER", + "type": "cryptographic-asset" + }, + { + "bom-ref": "dummy-CIP:UNKNOWN", + "cryptoProperties": { + "algorithmProperties": { + "certificationLevel": [ + "unknown" + ] + }, + "assetType": "algorithm" + }, + "name": "CryptoCertificationLevel: UNKNOWN", + "type": "cryptographic-asset" + } + ], + "dependencies": [ + { + "ref": "dummy-CIP:CC_EAL1" + }, + { + "ref": "dummy-CIP:CC_EAL1_PLUS" + }, + { + "ref": "dummy-CIP:CC_EAL2" + }, + { + "ref": "dummy-CIP:CC_EAL2_PLUS" + }, + { + "ref": "dummy-CIP:CC_EAL3" + }, + { + "ref": "dummy-CIP:CC_EAL3_PLUS" + }, + { + "ref": "dummy-CIP:CC_EAL4" + }, + { + "ref": "dummy-CIP:CC_EAL4_PLUS" + }, + { + "ref": "dummy-CIP:CC_EAL5" + }, + { + "ref": "dummy-CIP:CC_EAL5_PLUS" + }, + { + "ref": "dummy-CIP:CC_EAL6" + }, + { + "ref": "dummy-CIP:CC_EAL6_PLUS" + }, + { + "ref": "dummy-CIP:CC_EAL7" + }, + { + "ref": "dummy-CIP:CC_EAL7_PLUS" + }, + { + "ref": "dummy-CIP:FIPS140_1_L1" + }, + { + "ref": "dummy-CIP:FIPS140_1_L2" + }, + { + "ref": "dummy-CIP:FIPS140_1_L3" + }, + { + "ref": "dummy-CIP:FIPS140_1_L4" + }, + { + "ref": "dummy-CIP:FIPS140_2_L1" + }, + { + "ref": "dummy-CIP:FIPS140_2_L2" + }, + { + "ref": "dummy-CIP:FIPS140_2_L3" + }, + { + "ref": "dummy-CIP:FIPS140_2_L4" + }, + { + "ref": "dummy-CIP:FIPS140_3_L1" + }, + { + "ref": "dummy-CIP:FIPS140_3_L2" + }, + { + "ref": "dummy-CIP:FIPS140_3_L3" + }, + { + "ref": "dummy-CIP:FIPS140_3_L4" + }, + { + "ref": "dummy-CIP:NONE" + }, + { + "ref": "dummy-CIP:OTHER" + }, + { + "ref": "dummy-CIP:UNKNOWN" + } + ], + "metadata": { + "timestamp": "2023-01-07T13:44:32.312678+00:00" + }, + "properties": [ + { + "name": "key1", + "value": "val1" + }, + { + "name": "key2", + "value": "val2" + } + ], + "serialNumber": "urn:uuid:1441d33a-e0fc-45b5-af3b-61ee52a88bac", + "version": 1, + "$schema": "http://cyclonedx.org/schema/bom-1.6.schema.json", + "bomFormat": "CycloneDX", + "specVersion": "1.6" +} \ No newline at end of file diff --git a/tests/_data/snapshots/enum_CryptoCertificationLevel-1.6.xml.bin b/tests/_data/snapshots/enum_CryptoCertificationLevel-1.6.xml.bin new file mode 100644 index 000000000..3915c3edd --- /dev/null +++ b/tests/_data/snapshots/enum_CryptoCertificationLevel-1.6.xml.bin @@ -0,0 +1,304 @@ + + + + 2023-01-07T13:44:32.312678+00:00 + + + + CryptoCertificationLevel: CC_EAL1 + + algorithm + + cc-eal1 + + + + + CryptoCertificationLevel: CC_EAL1_PLUS + + algorithm + + cc-eal1+ + + + + + CryptoCertificationLevel: CC_EAL2 + + algorithm + + cc-eal2 + + + + + CryptoCertificationLevel: CC_EAL2_PLUS + + algorithm + + cc-eal2+ + + + + + CryptoCertificationLevel: CC_EAL3 + + algorithm + + cc-eal3 + + + + + CryptoCertificationLevel: CC_EAL3_PLUS + + algorithm + + cc-eal3+ + + + + + CryptoCertificationLevel: CC_EAL4 + + algorithm + + cc-eal4 + + + + + CryptoCertificationLevel: CC_EAL4_PLUS + + algorithm + + cc-eal4+ + + + + + CryptoCertificationLevel: CC_EAL5 + + algorithm + + cc-eal5 + + + + + CryptoCertificationLevel: CC_EAL5_PLUS + + algorithm + + cc-eal5+ + + + + + CryptoCertificationLevel: CC_EAL6 + + algorithm + + cc-eal6 + + + + + CryptoCertificationLevel: CC_EAL6_PLUS + + algorithm + + cc-eal6+ + + + + + CryptoCertificationLevel: CC_EAL7 + + algorithm + + cc-eal7 + + + + + CryptoCertificationLevel: CC_EAL7_PLUS + + algorithm + + cc-eal7+ + + + + + CryptoCertificationLevel: FIPS140_1_L1 + + algorithm + + fips140-1-l1 + + + + + CryptoCertificationLevel: FIPS140_1_L2 + + algorithm + + fips140-1-l2 + + + + + CryptoCertificationLevel: FIPS140_1_L3 + + algorithm + + fips140-1-l3 + + + + + CryptoCertificationLevel: FIPS140_1_L4 + + algorithm + + fips140-1-l4 + + + + + CryptoCertificationLevel: FIPS140_2_L1 + + algorithm + + fips140-2-l1 + + + + + CryptoCertificationLevel: FIPS140_2_L2 + + algorithm + + fips140-2-l2 + + + + + CryptoCertificationLevel: FIPS140_2_L3 + + algorithm + + fips140-2-l3 + + + + + CryptoCertificationLevel: FIPS140_2_L4 + + algorithm + + fips140-2-l4 + + + + + CryptoCertificationLevel: FIPS140_3_L1 + + algorithm + + fips140-3-l1 + + + + + CryptoCertificationLevel: FIPS140_3_L2 + + algorithm + + fips140-3-l2 + + + + + CryptoCertificationLevel: FIPS140_3_L3 + + algorithm + + fips140-3-l3 + + + + + CryptoCertificationLevel: FIPS140_3_L4 + + algorithm + + fips140-3-l4 + + + + + CryptoCertificationLevel: NONE + + algorithm + + none + + + + + CryptoCertificationLevel: OTHER + + algorithm + + other + + + + + CryptoCertificationLevel: UNKNOWN + + algorithm + + unknown + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + val1 + val2 + + diff --git a/tests/_data/snapshots/enum_CryptoCertificationLevel-1.7.json.bin b/tests/_data/snapshots/enum_CryptoCertificationLevel-1.7.json.bin new file mode 100644 index 000000000..38cf174dd --- /dev/null +++ b/tests/_data/snapshots/enum_CryptoCertificationLevel-1.7.json.bin @@ -0,0 +1,488 @@ +{ + "components": [ + { + "bom-ref": "dummy-CIP:CC_EAL1", + "cryptoProperties": { + "algorithmProperties": { + "certificationLevel": [ + "cc-eal1" + ] + }, + "assetType": "algorithm" + }, + "name": "CryptoCertificationLevel: CC_EAL1", + "type": "cryptographic-asset" + }, + { + "bom-ref": "dummy-CIP:CC_EAL1_PLUS", + "cryptoProperties": { + "algorithmProperties": { + "certificationLevel": [ + "cc-eal1+" + ] + }, + "assetType": "algorithm" + }, + "name": "CryptoCertificationLevel: CC_EAL1_PLUS", + "type": "cryptographic-asset" + }, + { + "bom-ref": "dummy-CIP:CC_EAL2", + "cryptoProperties": { + "algorithmProperties": { + "certificationLevel": [ + "cc-eal2" + ] + }, + "assetType": "algorithm" + }, + "name": "CryptoCertificationLevel: CC_EAL2", + "type": "cryptographic-asset" + }, + { + "bom-ref": "dummy-CIP:CC_EAL2_PLUS", + "cryptoProperties": { + "algorithmProperties": { + "certificationLevel": [ + "cc-eal2+" + ] + }, + "assetType": "algorithm" + }, + "name": "CryptoCertificationLevel: CC_EAL2_PLUS", + "type": "cryptographic-asset" + }, + { + "bom-ref": "dummy-CIP:CC_EAL3", + "cryptoProperties": { + "algorithmProperties": { + "certificationLevel": [ + "cc-eal3" + ] + }, + "assetType": "algorithm" + }, + "name": "CryptoCertificationLevel: CC_EAL3", + "type": "cryptographic-asset" + }, + { + "bom-ref": "dummy-CIP:CC_EAL3_PLUS", + "cryptoProperties": { + "algorithmProperties": { + "certificationLevel": [ + "cc-eal3+" + ] + }, + "assetType": "algorithm" + }, + "name": "CryptoCertificationLevel: CC_EAL3_PLUS", + "type": "cryptographic-asset" + }, + { + "bom-ref": "dummy-CIP:CC_EAL4", + "cryptoProperties": { + "algorithmProperties": { + "certificationLevel": [ + "cc-eal4" + ] + }, + "assetType": "algorithm" + }, + "name": "CryptoCertificationLevel: CC_EAL4", + "type": "cryptographic-asset" + }, + { + "bom-ref": "dummy-CIP:CC_EAL4_PLUS", + "cryptoProperties": { + "algorithmProperties": { + "certificationLevel": [ + "cc-eal4+" + ] + }, + "assetType": "algorithm" + }, + "name": "CryptoCertificationLevel: CC_EAL4_PLUS", + "type": "cryptographic-asset" + }, + { + "bom-ref": "dummy-CIP:CC_EAL5", + "cryptoProperties": { + "algorithmProperties": { + "certificationLevel": [ + "cc-eal5" + ] + }, + "assetType": "algorithm" + }, + "name": "CryptoCertificationLevel: CC_EAL5", + "type": "cryptographic-asset" + }, + { + "bom-ref": "dummy-CIP:CC_EAL5_PLUS", + "cryptoProperties": { + "algorithmProperties": { + "certificationLevel": [ + "cc-eal5+" + ] + }, + "assetType": "algorithm" + }, + "name": "CryptoCertificationLevel: CC_EAL5_PLUS", + "type": "cryptographic-asset" + }, + { + "bom-ref": "dummy-CIP:CC_EAL6", + "cryptoProperties": { + "algorithmProperties": { + "certificationLevel": [ + "cc-eal6" + ] + }, + "assetType": "algorithm" + }, + "name": "CryptoCertificationLevel: CC_EAL6", + "type": "cryptographic-asset" + }, + { + "bom-ref": "dummy-CIP:CC_EAL6_PLUS", + "cryptoProperties": { + "algorithmProperties": { + "certificationLevel": [ + "cc-eal6+" + ] + }, + "assetType": "algorithm" + }, + "name": "CryptoCertificationLevel: CC_EAL6_PLUS", + "type": "cryptographic-asset" + }, + { + "bom-ref": "dummy-CIP:CC_EAL7", + "cryptoProperties": { + "algorithmProperties": { + "certificationLevel": [ + "cc-eal7" + ] + }, + "assetType": "algorithm" + }, + "name": "CryptoCertificationLevel: CC_EAL7", + "type": "cryptographic-asset" + }, + { + "bom-ref": "dummy-CIP:CC_EAL7_PLUS", + "cryptoProperties": { + "algorithmProperties": { + "certificationLevel": [ + "cc-eal7+" + ] + }, + "assetType": "algorithm" + }, + "name": "CryptoCertificationLevel: CC_EAL7_PLUS", + "type": "cryptographic-asset" + }, + { + "bom-ref": "dummy-CIP:FIPS140_1_L1", + "cryptoProperties": { + "algorithmProperties": { + "certificationLevel": [ + "fips140-1-l1" + ] + }, + "assetType": "algorithm" + }, + "name": "CryptoCertificationLevel: FIPS140_1_L1", + "type": "cryptographic-asset" + }, + { + "bom-ref": "dummy-CIP:FIPS140_1_L2", + "cryptoProperties": { + "algorithmProperties": { + "certificationLevel": [ + "fips140-1-l2" + ] + }, + "assetType": "algorithm" + }, + "name": "CryptoCertificationLevel: FIPS140_1_L2", + "type": "cryptographic-asset" + }, + { + "bom-ref": "dummy-CIP:FIPS140_1_L3", + "cryptoProperties": { + "algorithmProperties": { + "certificationLevel": [ + "fips140-1-l3" + ] + }, + "assetType": "algorithm" + }, + "name": "CryptoCertificationLevel: FIPS140_1_L3", + "type": "cryptographic-asset" + }, + { + "bom-ref": "dummy-CIP:FIPS140_1_L4", + "cryptoProperties": { + "algorithmProperties": { + "certificationLevel": [ + "fips140-1-l4" + ] + }, + "assetType": "algorithm" + }, + "name": "CryptoCertificationLevel: FIPS140_1_L4", + "type": "cryptographic-asset" + }, + { + "bom-ref": "dummy-CIP:FIPS140_2_L1", + "cryptoProperties": { + "algorithmProperties": { + "certificationLevel": [ + "fips140-2-l1" + ] + }, + "assetType": "algorithm" + }, + "name": "CryptoCertificationLevel: FIPS140_2_L1", + "type": "cryptographic-asset" + }, + { + "bom-ref": "dummy-CIP:FIPS140_2_L2", + "cryptoProperties": { + "algorithmProperties": { + "certificationLevel": [ + "fips140-2-l2" + ] + }, + "assetType": "algorithm" + }, + "name": "CryptoCertificationLevel: FIPS140_2_L2", + "type": "cryptographic-asset" + }, + { + "bom-ref": "dummy-CIP:FIPS140_2_L3", + "cryptoProperties": { + "algorithmProperties": { + "certificationLevel": [ + "fips140-2-l3" + ] + }, + "assetType": "algorithm" + }, + "name": "CryptoCertificationLevel: FIPS140_2_L3", + "type": "cryptographic-asset" + }, + { + "bom-ref": "dummy-CIP:FIPS140_2_L4", + "cryptoProperties": { + "algorithmProperties": { + "certificationLevel": [ + "fips140-2-l4" + ] + }, + "assetType": "algorithm" + }, + "name": "CryptoCertificationLevel: FIPS140_2_L4", + "type": "cryptographic-asset" + }, + { + "bom-ref": "dummy-CIP:FIPS140_3_L1", + "cryptoProperties": { + "algorithmProperties": { + "certificationLevel": [ + "fips140-3-l1" + ] + }, + "assetType": "algorithm" + }, + "name": "CryptoCertificationLevel: FIPS140_3_L1", + "type": "cryptographic-asset" + }, + { + "bom-ref": "dummy-CIP:FIPS140_3_L2", + "cryptoProperties": { + "algorithmProperties": { + "certificationLevel": [ + "fips140-3-l2" + ] + }, + "assetType": "algorithm" + }, + "name": "CryptoCertificationLevel: FIPS140_3_L2", + "type": "cryptographic-asset" + }, + { + "bom-ref": "dummy-CIP:FIPS140_3_L3", + "cryptoProperties": { + "algorithmProperties": { + "certificationLevel": [ + "fips140-3-l3" + ] + }, + "assetType": "algorithm" + }, + "name": "CryptoCertificationLevel: FIPS140_3_L3", + "type": "cryptographic-asset" + }, + { + "bom-ref": "dummy-CIP:FIPS140_3_L4", + "cryptoProperties": { + "algorithmProperties": { + "certificationLevel": [ + "fips140-3-l4" + ] + }, + "assetType": "algorithm" + }, + "name": "CryptoCertificationLevel: FIPS140_3_L4", + "type": "cryptographic-asset" + }, + { + "bom-ref": "dummy-CIP:NONE", + "cryptoProperties": { + "algorithmProperties": { + "certificationLevel": [ + "none" + ] + }, + "assetType": "algorithm" + }, + "name": "CryptoCertificationLevel: NONE", + "type": "cryptographic-asset" + }, + { + "bom-ref": "dummy-CIP:OTHER", + "cryptoProperties": { + "algorithmProperties": { + "certificationLevel": [ + "other" + ] + }, + "assetType": "algorithm" + }, + "name": "CryptoCertificationLevel: OTHER", + "type": "cryptographic-asset" + }, + { + "bom-ref": "dummy-CIP:UNKNOWN", + "cryptoProperties": { + "algorithmProperties": { + "certificationLevel": [ + "unknown" + ] + }, + "assetType": "algorithm" + }, + "name": "CryptoCertificationLevel: UNKNOWN", + "type": "cryptographic-asset" + } + ], + "dependencies": [ + { + "ref": "dummy-CIP:CC_EAL1" + }, + { + "ref": "dummy-CIP:CC_EAL1_PLUS" + }, + { + "ref": "dummy-CIP:CC_EAL2" + }, + { + "ref": "dummy-CIP:CC_EAL2_PLUS" + }, + { + "ref": "dummy-CIP:CC_EAL3" + }, + { + "ref": "dummy-CIP:CC_EAL3_PLUS" + }, + { + "ref": "dummy-CIP:CC_EAL4" + }, + { + "ref": "dummy-CIP:CC_EAL4_PLUS" + }, + { + "ref": "dummy-CIP:CC_EAL5" + }, + { + "ref": "dummy-CIP:CC_EAL5_PLUS" + }, + { + "ref": "dummy-CIP:CC_EAL6" + }, + { + "ref": "dummy-CIP:CC_EAL6_PLUS" + }, + { + "ref": "dummy-CIP:CC_EAL7" + }, + { + "ref": "dummy-CIP:CC_EAL7_PLUS" + }, + { + "ref": "dummy-CIP:FIPS140_1_L1" + }, + { + "ref": "dummy-CIP:FIPS140_1_L2" + }, + { + "ref": "dummy-CIP:FIPS140_1_L3" + }, + { + "ref": "dummy-CIP:FIPS140_1_L4" + }, + { + "ref": "dummy-CIP:FIPS140_2_L1" + }, + { + "ref": "dummy-CIP:FIPS140_2_L2" + }, + { + "ref": "dummy-CIP:FIPS140_2_L3" + }, + { + "ref": "dummy-CIP:FIPS140_2_L4" + }, + { + "ref": "dummy-CIP:FIPS140_3_L1" + }, + { + "ref": "dummy-CIP:FIPS140_3_L2" + }, + { + "ref": "dummy-CIP:FIPS140_3_L3" + }, + { + "ref": "dummy-CIP:FIPS140_3_L4" + }, + { + "ref": "dummy-CIP:NONE" + }, + { + "ref": "dummy-CIP:OTHER" + }, + { + "ref": "dummy-CIP:UNKNOWN" + } + ], + "metadata": { + "timestamp": "2023-01-07T13:44:32.312678+00:00" + }, + "properties": [ + { + "name": "key1", + "value": "val1" + }, + { + "name": "key2", + "value": "val2" + } + ], + "serialNumber": "urn:uuid:1441d33a-e0fc-45b5-af3b-61ee52a88bac", + "version": 1, + "$schema": "http://cyclonedx.org/schema/bom-1.7.schema.json", + "bomFormat": "CycloneDX", + "specVersion": "1.7" +} \ No newline at end of file diff --git a/tests/_data/snapshots/enum_CryptoCertificationLevel-1.7.xml.bin b/tests/_data/snapshots/enum_CryptoCertificationLevel-1.7.xml.bin new file mode 100644 index 000000000..a4cbd6386 --- /dev/null +++ b/tests/_data/snapshots/enum_CryptoCertificationLevel-1.7.xml.bin @@ -0,0 +1,304 @@ + + + + 2023-01-07T13:44:32.312678+00:00 + + + + CryptoCertificationLevel: CC_EAL1 + + algorithm + + cc-eal1 + + + + + CryptoCertificationLevel: CC_EAL1_PLUS + + algorithm + + cc-eal1+ + + + + + CryptoCertificationLevel: CC_EAL2 + + algorithm + + cc-eal2 + + + + + CryptoCertificationLevel: CC_EAL2_PLUS + + algorithm + + cc-eal2+ + + + + + CryptoCertificationLevel: CC_EAL3 + + algorithm + + cc-eal3 + + + + + CryptoCertificationLevel: CC_EAL3_PLUS + + algorithm + + cc-eal3+ + + + + + CryptoCertificationLevel: CC_EAL4 + + algorithm + + cc-eal4 + + + + + CryptoCertificationLevel: CC_EAL4_PLUS + + algorithm + + cc-eal4+ + + + + + CryptoCertificationLevel: CC_EAL5 + + algorithm + + cc-eal5 + + + + + CryptoCertificationLevel: CC_EAL5_PLUS + + algorithm + + cc-eal5+ + + + + + CryptoCertificationLevel: CC_EAL6 + + algorithm + + cc-eal6 + + + + + CryptoCertificationLevel: CC_EAL6_PLUS + + algorithm + + cc-eal6+ + + + + + CryptoCertificationLevel: CC_EAL7 + + algorithm + + cc-eal7 + + + + + CryptoCertificationLevel: CC_EAL7_PLUS + + algorithm + + cc-eal7+ + + + + + CryptoCertificationLevel: FIPS140_1_L1 + + algorithm + + fips140-1-l1 + + + + + CryptoCertificationLevel: FIPS140_1_L2 + + algorithm + + fips140-1-l2 + + + + + CryptoCertificationLevel: FIPS140_1_L3 + + algorithm + + fips140-1-l3 + + + + + CryptoCertificationLevel: FIPS140_1_L4 + + algorithm + + fips140-1-l4 + + + + + CryptoCertificationLevel: FIPS140_2_L1 + + algorithm + + fips140-2-l1 + + + + + CryptoCertificationLevel: FIPS140_2_L2 + + algorithm + + fips140-2-l2 + + + + + CryptoCertificationLevel: FIPS140_2_L3 + + algorithm + + fips140-2-l3 + + + + + CryptoCertificationLevel: FIPS140_2_L4 + + algorithm + + fips140-2-l4 + + + + + CryptoCertificationLevel: FIPS140_3_L1 + + algorithm + + fips140-3-l1 + + + + + CryptoCertificationLevel: FIPS140_3_L2 + + algorithm + + fips140-3-l2 + + + + + CryptoCertificationLevel: FIPS140_3_L3 + + algorithm + + fips140-3-l3 + + + + + CryptoCertificationLevel: FIPS140_3_L4 + + algorithm + + fips140-3-l4 + + + + + CryptoCertificationLevel: NONE + + algorithm + + none + + + + + CryptoCertificationLevel: OTHER + + algorithm + + other + + + + + CryptoCertificationLevel: UNKNOWN + + algorithm + + unknown + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + val1 + val2 + + diff --git a/tests/test_enums.py b/tests/test_enums.py index a92b05c05..27b88fd0e 100644 --- a/tests/test_enums.py +++ b/tests/test_enums.py @@ -731,6 +731,33 @@ def test_cases_render_valid(self, of: OutputFormat, sv: SchemaVersion, *_: Any, super()._test_cases_render(bom, of, sv) +@ddt +class TestEnumCryptoCertificationLevel (_EnumTestCase): + + @idata(set(chain( + dp_cases_from_xml_schemas(f"./{SCHEMA_NS}complexType[@name='cryptoPropertiesType']/{SCHEMA_NS}sequence/{SCHEMA_NS}element[@name='algorithmProperties']/{SCHEMA_NS}complexType/{SCHEMA_NS}sequence/{SCHEMA_NS}element[@name='certificationLevel']/{SCHEMA_NS}simpleType"), + dp_cases_from_json_schemas('definitions', 'cryptoProperties', 'properties', 'algorithmProperties', 'properties', 'certificationLevel', 'items'), + ))) + def test_knows_value(self, value: str) -> None: + super()._test_knows_value(CryptoCertificationLevel, value) + + @named_data(*(d for d in NAMED_OF_SV if d[2] >= SchemaVersion.V1_6 )) + def test_cases_render_valid(self, of: OutputFormat, sv: SchemaVersion, *_: Any, **__: Any) -> None: + bom = _make_bom( + components=[ + Component( + name=f'CryptoCertificationLevel: {ccl.name}', bom_ref=f'dummy-CIP:{ccl.name}', + type=ComponentType.CRYPTOGRAPHIC_ASSET, + crypto_properties=CryptoProperties( + asset_type=CryptoAssetType.ALGORITHM, + algorithm_properties=AlgorithmProperties( + certification_levels=[ccl] + ) + ) + ) for ccl in CryptoCertificationLevel + ]) + super()._test_cases_render(bom, of, sv) + """ @ddt @@ -743,7 +770,7 @@ class TestEnum...(_EnumTestCase): def test_knows_value(self, value: str) -> None: super()._test_knows_value(..., value) - @named_data(*NAMED_OF_SV) + @named_data(*(d for d in NAMED_OF_SV if d[2] >= SchemaVersion.V1_6 )) def test_cases_render_valid(self, of: OutputFormat, sv: SchemaVersion, *_: Any, **__: Any) -> None: bom = _make_bom( components=[ From fef2e7c541178e310181773e7446310fb5a0bc67 Mon Sep 17 00:00:00 2001 From: Jan Kowalleck Date: Mon, 15 Jun 2026 12:14:12 +0200 Subject: [PATCH 18/19] tests: enum CryptoMode Signed-off-by: Jan Kowalleck --- cyclonedx/model/crypto.py | 2 ++ tests/test_enums.py | 31 +++++++++++++++++++++++++++++-- 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/cyclonedx/model/crypto.py b/cyclonedx/model/crypto.py index 012975f2b..6eee07d53 100644 --- a/cyclonedx/model/crypto.py +++ b/cyclonedx/model/crypto.py @@ -197,6 +197,8 @@ class CryptoCertificationLevel(str, Enum): @serializable.serializable_enum class CryptoMode(str, Enum): + # TODO: rename to `CryptoAlgorithmMode` + """ This is our internal representation of the cryptoPropertiesType.algorithmProperties.mode ENUM type within the CycloneDX standard. diff --git a/tests/test_enums.py b/tests/test_enums.py index 27b88fd0e..550f7e43a 100644 --- a/tests/test_enums.py +++ b/tests/test_enums.py @@ -759,6 +759,35 @@ def test_cases_render_valid(self, of: OutputFormat, sv: SchemaVersion, *_: Any, super()._test_cases_render(bom, of, sv) + +@ddt +class TestEnumCryptoMode(_EnumTestCase): + + @idata(set(chain( + dp_cases_from_xml_schemas(f"./{SCHEMA_NS}complexType[@name='cryptoPropertiesType']/{SCHEMA_NS}sequence/{SCHEMA_NS}element[@name='algorithmProperties']/{SCHEMA_NS}complexType/{SCHEMA_NS}sequence/{SCHEMA_NS}element[@name='mode']/{SCHEMA_NS}simpleType"), + dp_cases_from_json_schemas('definitions', 'cryptoProperties', 'properties', 'algorithmProperties', 'properties', 'mode'), + ))) + def test_knows_value(self, value: str) -> None: + super()._test_knows_value(CryptoMode, value) + + @named_data(*(d for d in NAMED_OF_SV if d[2] >= SchemaVersion.V1_6 )) + def test_cases_render_valid(self, of: OutputFormat, sv: SchemaVersion, *_: Any, **__: Any) -> None: + bom = _make_bom( + components=[ + Component( + name=f'CryptoMode: {cm.name}', bom_ref=f'dummy-CIP:{cm.name}', + type=ComponentType.CRYPTOGRAPHIC_ASSET, + crypto_properties=CryptoProperties( + asset_type=CryptoAssetType.ALGORITHM, + algorithm_properties=AlgorithmProperties( + mode=cm + ) + ) + ) for cm in CryptoMode + ]) + super()._test_cases_render(bom, of, sv) + + """ @ddt class TestEnum...(_EnumTestCase): @@ -782,8 +811,6 @@ def test_cases_render_valid(self, of: OutputFormat, sv: SchemaVersion, *_: Any, """ missing: -- CryptoCertificationLevel -- CryptoMode - CryptoPadding - CryptoFunction - RelatedCryptoMaterialType From 0c54bb45c7a24be97c0d7587ee6225dad1c97b62 Mon Sep 17 00:00:00 2001 From: Jan Kowalleck Date: Mon, 15 Jun 2026 12:14:16 +0200 Subject: [PATCH 19/19] tests: enum CryptoMode Signed-off-by: Jan Kowalleck --- .../snapshots/enum_CryptoMode-1.6.json.bin | 150 ++++++++++++++++++ .../snapshots/enum_CryptoMode-1.6.xml.bin | 104 ++++++++++++ .../snapshots/enum_CryptoMode-1.7.json.bin | 150 ++++++++++++++++++ .../snapshots/enum_CryptoMode-1.7.xml.bin | 104 ++++++++++++ 4 files changed, 508 insertions(+) create mode 100644 tests/_data/snapshots/enum_CryptoMode-1.6.json.bin create mode 100644 tests/_data/snapshots/enum_CryptoMode-1.6.xml.bin create mode 100644 tests/_data/snapshots/enum_CryptoMode-1.7.json.bin create mode 100644 tests/_data/snapshots/enum_CryptoMode-1.7.xml.bin diff --git a/tests/_data/snapshots/enum_CryptoMode-1.6.json.bin b/tests/_data/snapshots/enum_CryptoMode-1.6.json.bin new file mode 100644 index 000000000..c949862ac --- /dev/null +++ b/tests/_data/snapshots/enum_CryptoMode-1.6.json.bin @@ -0,0 +1,150 @@ +{ + "components": [ + { + "bom-ref": "dummy-CIP:CBC", + "cryptoProperties": { + "algorithmProperties": { + "mode": "cbc" + }, + "assetType": "algorithm" + }, + "name": "CryptoMode: CBC", + "type": "cryptographic-asset" + }, + { + "bom-ref": "dummy-CIP:CCM", + "cryptoProperties": { + "algorithmProperties": { + "mode": "ccm" + }, + "assetType": "algorithm" + }, + "name": "CryptoMode: CCM", + "type": "cryptographic-asset" + }, + { + "bom-ref": "dummy-CIP:CFB", + "cryptoProperties": { + "algorithmProperties": { + "mode": "cfb" + }, + "assetType": "algorithm" + }, + "name": "CryptoMode: CFB", + "type": "cryptographic-asset" + }, + { + "bom-ref": "dummy-CIP:CTR", + "cryptoProperties": { + "algorithmProperties": { + "mode": "ctr" + }, + "assetType": "algorithm" + }, + "name": "CryptoMode: CTR", + "type": "cryptographic-asset" + }, + { + "bom-ref": "dummy-CIP:ECB", + "cryptoProperties": { + "algorithmProperties": { + "mode": "ecb" + }, + "assetType": "algorithm" + }, + "name": "CryptoMode: ECB", + "type": "cryptographic-asset" + }, + { + "bom-ref": "dummy-CIP:GCM", + "cryptoProperties": { + "algorithmProperties": { + "mode": "gcm" + }, + "assetType": "algorithm" + }, + "name": "CryptoMode: GCM", + "type": "cryptographic-asset" + }, + { + "bom-ref": "dummy-CIP:OFB", + "cryptoProperties": { + "algorithmProperties": { + "mode": "ofb" + }, + "assetType": "algorithm" + }, + "name": "CryptoMode: OFB", + "type": "cryptographic-asset" + }, + { + "bom-ref": "dummy-CIP:OTHER", + "cryptoProperties": { + "algorithmProperties": { + "mode": "other" + }, + "assetType": "algorithm" + }, + "name": "CryptoMode: OTHER", + "type": "cryptographic-asset" + }, + { + "bom-ref": "dummy-CIP:UNKNOWN", + "cryptoProperties": { + "algorithmProperties": { + "mode": "unknown" + }, + "assetType": "algorithm" + }, + "name": "CryptoMode: UNKNOWN", + "type": "cryptographic-asset" + } + ], + "dependencies": [ + { + "ref": "dummy-CIP:CBC" + }, + { + "ref": "dummy-CIP:CCM" + }, + { + "ref": "dummy-CIP:CFB" + }, + { + "ref": "dummy-CIP:CTR" + }, + { + "ref": "dummy-CIP:ECB" + }, + { + "ref": "dummy-CIP:GCM" + }, + { + "ref": "dummy-CIP:OFB" + }, + { + "ref": "dummy-CIP:OTHER" + }, + { + "ref": "dummy-CIP:UNKNOWN" + } + ], + "metadata": { + "timestamp": "2023-01-07T13:44:32.312678+00:00" + }, + "properties": [ + { + "name": "key1", + "value": "val1" + }, + { + "name": "key2", + "value": "val2" + } + ], + "serialNumber": "urn:uuid:1441d33a-e0fc-45b5-af3b-61ee52a88bac", + "version": 1, + "$schema": "http://cyclonedx.org/schema/bom-1.6.schema.json", + "bomFormat": "CycloneDX", + "specVersion": "1.6" +} \ No newline at end of file diff --git a/tests/_data/snapshots/enum_CryptoMode-1.6.xml.bin b/tests/_data/snapshots/enum_CryptoMode-1.6.xml.bin new file mode 100644 index 000000000..db49f73d9 --- /dev/null +++ b/tests/_data/snapshots/enum_CryptoMode-1.6.xml.bin @@ -0,0 +1,104 @@ + + + + 2023-01-07T13:44:32.312678+00:00 + + + + CryptoMode: CBC + + algorithm + + cbc + + + + + CryptoMode: CCM + + algorithm + + ccm + + + + + CryptoMode: CFB + + algorithm + + cfb + + + + + CryptoMode: CTR + + algorithm + + ctr + + + + + CryptoMode: ECB + + algorithm + + ecb + + + + + CryptoMode: GCM + + algorithm + + gcm + + + + + CryptoMode: OFB + + algorithm + + ofb + + + + + CryptoMode: OTHER + + algorithm + + other + + + + + CryptoMode: UNKNOWN + + algorithm + + unknown + + + + + + + + + + + + + + + + + val1 + val2 + + diff --git a/tests/_data/snapshots/enum_CryptoMode-1.7.json.bin b/tests/_data/snapshots/enum_CryptoMode-1.7.json.bin new file mode 100644 index 000000000..5275eba9e --- /dev/null +++ b/tests/_data/snapshots/enum_CryptoMode-1.7.json.bin @@ -0,0 +1,150 @@ +{ + "components": [ + { + "bom-ref": "dummy-CIP:CBC", + "cryptoProperties": { + "algorithmProperties": { + "mode": "cbc" + }, + "assetType": "algorithm" + }, + "name": "CryptoMode: CBC", + "type": "cryptographic-asset" + }, + { + "bom-ref": "dummy-CIP:CCM", + "cryptoProperties": { + "algorithmProperties": { + "mode": "ccm" + }, + "assetType": "algorithm" + }, + "name": "CryptoMode: CCM", + "type": "cryptographic-asset" + }, + { + "bom-ref": "dummy-CIP:CFB", + "cryptoProperties": { + "algorithmProperties": { + "mode": "cfb" + }, + "assetType": "algorithm" + }, + "name": "CryptoMode: CFB", + "type": "cryptographic-asset" + }, + { + "bom-ref": "dummy-CIP:CTR", + "cryptoProperties": { + "algorithmProperties": { + "mode": "ctr" + }, + "assetType": "algorithm" + }, + "name": "CryptoMode: CTR", + "type": "cryptographic-asset" + }, + { + "bom-ref": "dummy-CIP:ECB", + "cryptoProperties": { + "algorithmProperties": { + "mode": "ecb" + }, + "assetType": "algorithm" + }, + "name": "CryptoMode: ECB", + "type": "cryptographic-asset" + }, + { + "bom-ref": "dummy-CIP:GCM", + "cryptoProperties": { + "algorithmProperties": { + "mode": "gcm" + }, + "assetType": "algorithm" + }, + "name": "CryptoMode: GCM", + "type": "cryptographic-asset" + }, + { + "bom-ref": "dummy-CIP:OFB", + "cryptoProperties": { + "algorithmProperties": { + "mode": "ofb" + }, + "assetType": "algorithm" + }, + "name": "CryptoMode: OFB", + "type": "cryptographic-asset" + }, + { + "bom-ref": "dummy-CIP:OTHER", + "cryptoProperties": { + "algorithmProperties": { + "mode": "other" + }, + "assetType": "algorithm" + }, + "name": "CryptoMode: OTHER", + "type": "cryptographic-asset" + }, + { + "bom-ref": "dummy-CIP:UNKNOWN", + "cryptoProperties": { + "algorithmProperties": { + "mode": "unknown" + }, + "assetType": "algorithm" + }, + "name": "CryptoMode: UNKNOWN", + "type": "cryptographic-asset" + } + ], + "dependencies": [ + { + "ref": "dummy-CIP:CBC" + }, + { + "ref": "dummy-CIP:CCM" + }, + { + "ref": "dummy-CIP:CFB" + }, + { + "ref": "dummy-CIP:CTR" + }, + { + "ref": "dummy-CIP:ECB" + }, + { + "ref": "dummy-CIP:GCM" + }, + { + "ref": "dummy-CIP:OFB" + }, + { + "ref": "dummy-CIP:OTHER" + }, + { + "ref": "dummy-CIP:UNKNOWN" + } + ], + "metadata": { + "timestamp": "2023-01-07T13:44:32.312678+00:00" + }, + "properties": [ + { + "name": "key1", + "value": "val1" + }, + { + "name": "key2", + "value": "val2" + } + ], + "serialNumber": "urn:uuid:1441d33a-e0fc-45b5-af3b-61ee52a88bac", + "version": 1, + "$schema": "http://cyclonedx.org/schema/bom-1.7.schema.json", + "bomFormat": "CycloneDX", + "specVersion": "1.7" +} \ No newline at end of file diff --git a/tests/_data/snapshots/enum_CryptoMode-1.7.xml.bin b/tests/_data/snapshots/enum_CryptoMode-1.7.xml.bin new file mode 100644 index 000000000..25618f714 --- /dev/null +++ b/tests/_data/snapshots/enum_CryptoMode-1.7.xml.bin @@ -0,0 +1,104 @@ + + + + 2023-01-07T13:44:32.312678+00:00 + + + + CryptoMode: CBC + + algorithm + + cbc + + + + + CryptoMode: CCM + + algorithm + + ccm + + + + + CryptoMode: CFB + + algorithm + + cfb + + + + + CryptoMode: CTR + + algorithm + + ctr + + + + + CryptoMode: ECB + + algorithm + + ecb + + + + + CryptoMode: GCM + + algorithm + + gcm + + + + + CryptoMode: OFB + + algorithm + + ofb + + + + + CryptoMode: OTHER + + algorithm + + other + + + + + CryptoMode: UNKNOWN + + algorithm + + unknown + + + + + + + + + + + + + + + + + val1 + val2 + +