-
-
Notifications
You must be signed in to change notification settings - Fork 65
feat: add support for Service.trustZone #980
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,6 +17,7 @@ | |
|
|
||
|
|
||
| from collections.abc import Callable | ||
| from io import StringIO | ||
| from json import loads as json_loads | ||
| from os.path import join | ||
| from typing import Any | ||
|
|
@@ -27,6 +28,9 @@ | |
|
|
||
| from cyclonedx.model.bom import Bom | ||
| from cyclonedx.model.license import DisjunctiveLicense, LicenseExpression, LicenseRepository | ||
| from cyclonedx.model.service import Service | ||
| from cyclonedx.output.json import BY_SCHEMA_VERSION as JSON_BY_SCHEMA_VERSION | ||
| from cyclonedx.output.xml import BY_SCHEMA_VERSION as XML_BY_SCHEMA_VERSION | ||
| from cyclonedx.schema import OutputFormat, SchemaVersion | ||
| from tests import OWN_DATA_DIRECTORY, DeepCompareMixin, SnapshotMixin, mksname | ||
| from tests._data.models import ( | ||
|
|
@@ -130,6 +134,31 @@ def test_regression_issue690(self) -> None: | |
| bom: Bom = Bom.from_json(json) # <<< is expected to not crash | ||
| self.assertIsNotNone(bom) | ||
|
|
||
| def test_service_trust_zone_from_json(self) -> None: | ||
| bom = Bom.from_json({ | ||
| 'bomFormat': 'CycloneDX', | ||
| 'specVersion': '1.7', | ||
| 'version': 1, | ||
| 'services': [ | ||
| { | ||
| 'bom-ref': 'svc-ref', | ||
| 'name': 'svc', | ||
| 'trustZone': 'internal-vpc', | ||
| } | ||
| ], | ||
| }) | ||
| self.assertEqual('internal-vpc', next(iter(bom.services)).trust_zone) | ||
|
|
||
| def test_service_trust_zone_json_to_xml_roundtrip(self) -> None: | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why is this test needed? |
||
| bom = Bom(services=[ | ||
| Service(name='svc', bom_ref='svc-ref', trust_zone='internal-vpc') | ||
| ]) | ||
| json_text = JSON_BY_SCHEMA_VERSION[SchemaVersion.V1_7](bom).output_as_string() | ||
| json_bom = Bom.from_json(json_loads(json_text)) | ||
| xml_text = XML_BY_SCHEMA_VERSION[SchemaVersion.V1_7](json_bom).output_as_string() | ||
| xml_bom = Bom.from_xml(StringIO(xml_text)) | ||
| self.assertEqual('internal-vpc', next(iter(xml_bom.services)).trust_zone) | ||
|
|
||
| def test_component_evidence_identity(self) -> None: | ||
| json_file = join(OWN_DATA_DIRECTORY, 'json', | ||
| SchemaVersion.V1_6.to_version(), | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,6 +16,7 @@ | |
| # Copyright (c) OWASP Foundation. All Rights Reserved. | ||
|
|
||
| from collections.abc import Callable | ||
| from io import StringIO | ||
| from os.path import join | ||
| from typing import Any | ||
| from unittest import TestCase | ||
|
|
@@ -50,6 +51,19 @@ def test_prepared(self, get_bom: Callable[[], Bom], *_: Any, **__: Any) -> None: | |
| self.assertBomDeepEqual(expected, bom, | ||
| fuzzy_deps=get_bom in all_get_bom_funct_with_incomplete_deps) | ||
|
|
||
| def test_service_trust_zone_from_xml(self) -> None: | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why is this test needed? |
||
| bom = Bom.from_xml(StringIO("""<?xml version="1.0" encoding="UTF-8"?> | ||
| <bom xmlns="http://cyclonedx.org/schema/bom/1.7" version="1"> | ||
| <services> | ||
| <service bom-ref="svc-ref"> | ||
| <name>svc</name> | ||
| <trustZone>internal-vpc</trustZone> | ||
| </service> | ||
| </services> | ||
| </bom> | ||
| """)) | ||
| self.assertEqual('internal-vpc', next(iter(bom.services)).trust_zone) | ||
|
|
||
| def test_component_evidence_identity(self) -> None: | ||
| xml_file = join(OWN_DATA_DIRECTORY, 'xml', | ||
| SchemaVersion.V1_6.to_version(), | ||
|
|
||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (de)serzialization tests are automatically done with all the test models. |
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (de)serzialization tests are automatically done with all the test models. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is this test needed?