diff --git a/cyclonedx/builder/__init__.py b/cyclonedx/builder/__init__.py new file mode 100644 index 00000000..9342de00 --- /dev/null +++ b/cyclonedx/builder/__init__.py @@ -0,0 +1,18 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# SPDX-License-Identifier: Apache-2.0 +# Copyright (c) OWASP Foundation. All Rights Reserved. + +""" +Builders used in this library. +""" diff --git a/cyclonedx/builder/this.py b/cyclonedx/builder/this.py new file mode 100644 index 00000000..ece1e428 --- /dev/null +++ b/cyclonedx/builder/this.py @@ -0,0 +1,97 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# SPDX-License-Identifier: Apache-2.0 +# Copyright (c) OWASP Foundation. All Rights Reserved. + +"""Representation of this very python library.""" + +__all__ = ['this_tool', 'this_component'] + +from typing import Iterable + +from .. import __version__ as __ThisVersion # noqa: N812 +from ..model import ExternalReference, ExternalReferenceType, XsUri +from ..model.component import Component, ComponentType +from ..model.license import DisjunctiveLicense, LicenseAcknowledgement +from ..model.tool import Tool + +# !!! keep this file in sync with `pyproject.toml` + +# !!! +# things in here are built on demand, rather than using prepared frozen constants. +# this is currently a draft and may change in the future. +# !!! + + +def __ext_refs() -> Iterable[ExternalReference]: + return ( + ExternalReference( + type=ExternalReferenceType.BUILD_SYSTEM, + url=XsUri('https://github.com/CycloneDX/cyclonedx-python-lib/actions') + ), + ExternalReference( + type=ExternalReferenceType.DISTRIBUTION, + url=XsUri('https://pypi.org/project/cyclonedx-python-lib/') + ), + ExternalReference( + type=ExternalReferenceType.DOCUMENTATION, + url=XsUri('https://cyclonedx-python-library.readthedocs.io/') + ), + ExternalReference( + type=ExternalReferenceType.ISSUE_TRACKER, + url=XsUri('https://github.com/CycloneDX/cyclonedx-python-lib/issues') + ), + ExternalReference( + type=ExternalReferenceType.LICENSE, + url=XsUri('https://github.com/CycloneDX/cyclonedx-python-lib/blob/main/LICENSE') + ), + ExternalReference( + type=ExternalReferenceType.RELEASE_NOTES, + url=XsUri('https://github.com/CycloneDX/cyclonedx-python-lib/blob/main/CHANGELOG.md') + ), + ExternalReference( + type=ExternalReferenceType.VCS, + url=XsUri('https://github.com/CycloneDX/cyclonedx-python-lib') + ), + ExternalReference( + type=ExternalReferenceType.WEBSITE, + url=XsUri('https://github.com/CycloneDX/cyclonedx-python-lib/#readme') + ), + ) + + +def this_tool() -> Tool: + """Representation of this very python library as a :class:`Tool`.""" + + return Tool( + vendor='CycloneDX', + name='cyclonedx-python-lib', + version=__ThisVersion or 'UNKNOWN', + external_references=__ext_refs(), + ) + + +def this_component() -> Component: + """Representation of this very python library as a :class:`Component`.""" + + return Component( + type=ComponentType.LIBRARY, + group='CycloneDX', + name='cyclonedx-python-lib', + version=__ThisVersion or 'UNKNOWN', + description='Python library for CycloneDX', + licenses=(DisjunctiveLicense(id='Apache-2.0', + acknowledgement=LicenseAcknowledgement.DECLARED),), + external_references=__ext_refs(), + # to be expanded ... + ) diff --git a/cyclonedx/model/__init__.py b/cyclonedx/model/__init__.py index c074a701..df49680e 100644 --- a/cyclonedx/model/__init__.py +++ b/cyclonedx/model/__init__.py @@ -32,7 +32,6 @@ import serializable from sortedcontainers import SortedSet -from .. import __version__ as __ThisToolVersion # noqa: N812 from .._internal.compare import ComparableTuple as _ComparableTuple from ..exception.model import ( InvalidLocaleTypeException, @@ -1262,47 +1261,3 @@ def __hash__(self) -> int: def __repr__(self) -> str: return f'' - - -# Importing here to avoid a circular import -from .tool import Tool # pylint: disable=wrong-import-position # noqa: E402 - -ThisTool = Tool( - vendor='CycloneDX', - name='cyclonedx-python-lib', - version=__ThisToolVersion or 'UNKNOWN', - external_references=[ - ExternalReference( - type=ExternalReferenceType.BUILD_SYSTEM, - url=XsUri('https://github.com/CycloneDX/cyclonedx-python-lib/actions') - ), - ExternalReference( - type=ExternalReferenceType.DISTRIBUTION, - url=XsUri('https://pypi.org/project/cyclonedx-python-lib/') - ), - ExternalReference( - type=ExternalReferenceType.DOCUMENTATION, - url=XsUri('https://cyclonedx-python-library.readthedocs.io/') - ), - ExternalReference( - type=ExternalReferenceType.ISSUE_TRACKER, - url=XsUri('https://github.com/CycloneDX/cyclonedx-python-lib/issues') - ), - ExternalReference( - type=ExternalReferenceType.LICENSE, - url=XsUri('https://github.com/CycloneDX/cyclonedx-python-lib/blob/main/LICENSE') - ), - ExternalReference( - type=ExternalReferenceType.RELEASE_NOTES, - url=XsUri('https://github.com/CycloneDX/cyclonedx-python-lib/blob/main/CHANGELOG.md') - ), - ExternalReference( - type=ExternalReferenceType.VCS, - url=XsUri('https://github.com/CycloneDX/cyclonedx-python-lib') - ), - ExternalReference( - type=ExternalReferenceType.WEBSITE, - url=XsUri('https://github.com/CycloneDX/cyclonedx-python-lib/#readme') - ) - ] -) diff --git a/pyproject.toml b/pyproject.toml index 625d7999..14d698ae 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,6 +3,7 @@ requires = ["poetry-core>=1.0.0"] build-backend = "poetry.core.masonry.api" [tool.poetry] +# keep in sync with `cyclonedx/builder/this.py` name = "cyclonedx-python-lib" # !! version is managed by semantic_release version = "7.6.0" @@ -63,13 +64,14 @@ keywords = [ ] [tool.poetry.urls] +# keep in sync with `cyclonedx/builder/this.py` "Bug Tracker" = "https://github.com/CycloneDX/cyclonedx-python-lib/issues" "Funding" = "https://owasp.org/donate/?reponame=www-project-cyclonedx&title=OWASP+CycloneDX" [tool.poetry.dependencies] python = "^3.8" packageurl-python = ">=0.11, <2" -py-serializable = "^1.1.0" +py-serializable = "^1.1.1" sortedcontainers = "^2.4.0" license-expression = "^30" jsonschema = { version = "^4.18", extras=['format'], optional=true } diff --git a/tests/_data/models.py b/tests/_data/models.py index 0939f1ee..dd38a8c3 100644 --- a/tests/_data/models.py +++ b/tests/_data/models.py @@ -26,6 +26,7 @@ # See https://github.com/package-url/packageurl-python/issues/65 from packageurl import PackageURL +from cyclonedx.builder.this import this_component, this_tool from cyclonedx.model import ( AttachedText, Copyright, @@ -38,7 +39,6 @@ Note, NoteText, Property, - ThisTool, XsUri, ) from cyclonedx.model.bom import Bom, BomMetaData @@ -1052,7 +1052,7 @@ def get_bom_with_tools() -> Bom: return _make_bom( metadata=BomMetaData( tools=( - ThisTool, + this_tool(), Tool(name='test-tool-b'), Tool(vendor='example', name='test-tool-a', @@ -1071,6 +1071,7 @@ def get_bom_with_tools_with_component_migrate() -> Bom: metadata=BomMetaData( tools=ToolsRepository( components=( + this_component(), Component(name='test-component', bom_ref='test-component'), Component(type=ComponentType.APPLICATION, bom_ref='other-component', @@ -1108,6 +1109,7 @@ def get_bom_with_tools_with_component_and_service_migrate() -> Bom: metadata=BomMetaData( tools=ToolsRepository( components=( + this_component(), Component(name='test-component', bom_ref='test-component'), Component(type=ComponentType.APPLICATION, bom_ref='other-component', @@ -1137,6 +1139,7 @@ def get_bom_with_tools_with_component_and_service_and_tools_irreversible_migrate tserv = tools.services ttools = tools.tools tcomp.update(( + this_component(), Component(name='test-component', bom_ref='test-component'), Component(type=ComponentType.APPLICATION, bom_ref='other-component', @@ -1156,7 +1159,7 @@ def get_bom_with_tools_with_component_and_service_and_tools_irreversible_migrate ), )) ttools.update(( - ThisTool, + this_tool(), Tool(name='test-tool-b'), Tool(vendor='example', name='test-tool-a', diff --git a/tests/_data/snapshots/get_bom_with_tools_with_component_and_service_and_tools_irreversible_migrate-1.2.json.bin b/tests/_data/snapshots/get_bom_with_tools_with_component_and_service_and_tools_irreversible_migrate-1.2.json.bin index 1fd2b7d6..7aa7bc43 100644 --- a/tests/_data/snapshots/get_bom_with_tools_with_component_and_service_and_tools_irreversible_migrate-1.2.json.bin +++ b/tests/_data/snapshots/get_bom_with_tools_with_component_and_service_and_tools_irreversible_migrate-1.2.json.bin @@ -31,6 +31,11 @@ "name": "other-component", "vendor": "acme" }, + { + "name": "cyclonedx-python-lib", + "vendor": "CycloneDX", + "version": "TESTING" + }, { "name": "test-component" }, diff --git a/tests/_data/snapshots/get_bom_with_tools_with_component_and_service_and_tools_irreversible_migrate-1.2.xml.bin b/tests/_data/snapshots/get_bom_with_tools_with_component_and_service_and_tools_irreversible_migrate-1.2.xml.bin index d8b2a4c1..ff3213ee 100644 --- a/tests/_data/snapshots/get_bom_with_tools_with_component_and_service_and_tools_irreversible_migrate-1.2.xml.bin +++ b/tests/_data/snapshots/get_bom_with_tools_with_component_and_service_and_tools_irreversible_migrate-1.2.xml.bin @@ -26,6 +26,11 @@ 49b420bd8d8182542a76d4422e0c7890dcc88a3d8ddad04da06366d8c40ac8ca + + CycloneDX + cyclonedx-python-lib + TESTING + test-component diff --git a/tests/_data/snapshots/get_bom_with_tools_with_component_and_service_and_tools_irreversible_migrate-1.3.json.bin b/tests/_data/snapshots/get_bom_with_tools_with_component_and_service_and_tools_irreversible_migrate-1.3.json.bin index 01886ae2..258f92e2 100644 --- a/tests/_data/snapshots/get_bom_with_tools_with_component_and_service_and_tools_irreversible_migrate-1.3.json.bin +++ b/tests/_data/snapshots/get_bom_with_tools_with_component_and_service_and_tools_irreversible_migrate-1.3.json.bin @@ -31,6 +31,11 @@ "name": "other-component", "vendor": "acme" }, + { + "name": "cyclonedx-python-lib", + "vendor": "CycloneDX", + "version": "TESTING" + }, { "name": "test-component" }, diff --git a/tests/_data/snapshots/get_bom_with_tools_with_component_and_service_and_tools_irreversible_migrate-1.3.xml.bin b/tests/_data/snapshots/get_bom_with_tools_with_component_and_service_and_tools_irreversible_migrate-1.3.xml.bin index b0d0956c..014efb51 100644 --- a/tests/_data/snapshots/get_bom_with_tools_with_component_and_service_and_tools_irreversible_migrate-1.3.xml.bin +++ b/tests/_data/snapshots/get_bom_with_tools_with_component_and_service_and_tools_irreversible_migrate-1.3.xml.bin @@ -26,6 +26,11 @@ 49b420bd8d8182542a76d4422e0c7890dcc88a3d8ddad04da06366d8c40ac8ca + + CycloneDX + cyclonedx-python-lib + TESTING + test-component diff --git a/tests/_data/snapshots/get_bom_with_tools_with_component_and_service_and_tools_irreversible_migrate-1.4.json.bin b/tests/_data/snapshots/get_bom_with_tools_with_component_and_service_and_tools_irreversible_migrate-1.4.json.bin index 5dd3c4d1..65e7df8b 100644 --- a/tests/_data/snapshots/get_bom_with_tools_with_component_and_service_and_tools_irreversible_migrate-1.4.json.bin +++ b/tests/_data/snapshots/get_bom_with_tools_with_component_and_service_and_tools_irreversible_migrate-1.4.json.bin @@ -91,6 +91,45 @@ "name": "other-component", "vendor": "acme" }, + { + "externalReferences": [ + { + "type": "build-system", + "url": "https://github.com/CycloneDX/cyclonedx-python-lib/actions" + }, + { + "type": "distribution", + "url": "https://pypi.org/project/cyclonedx-python-lib/" + }, + { + "type": "documentation", + "url": "https://cyclonedx-python-library.readthedocs.io/" + }, + { + "type": "issue-tracker", + "url": "https://github.com/CycloneDX/cyclonedx-python-lib/issues" + }, + { + "type": "license", + "url": "https://github.com/CycloneDX/cyclonedx-python-lib/blob/main/LICENSE" + }, + { + "type": "release-notes", + "url": "https://github.com/CycloneDX/cyclonedx-python-lib/blob/main/CHANGELOG.md" + }, + { + "type": "vcs", + "url": "https://github.com/CycloneDX/cyclonedx-python-lib" + }, + { + "type": "website", + "url": "https://github.com/CycloneDX/cyclonedx-python-lib/#readme" + } + ], + "name": "cyclonedx-python-lib", + "vendor": "CycloneDX", + "version": "TESTING" + }, { "name": "test-component" }, diff --git a/tests/_data/snapshots/get_bom_with_tools_with_component_and_service_and_tools_irreversible_migrate-1.4.xml.bin b/tests/_data/snapshots/get_bom_with_tools_with_component_and_service_and_tools_irreversible_migrate-1.4.xml.bin index 4144e524..f7f59286 100644 --- a/tests/_data/snapshots/get_bom_with_tools_with_component_and_service_and_tools_irreversible_migrate-1.4.xml.bin +++ b/tests/_data/snapshots/get_bom_with_tools_with_component_and_service_and_tools_irreversible_migrate-1.4.xml.bin @@ -70,6 +70,37 @@ + + CycloneDX + cyclonedx-python-lib + TESTING + + + https://github.com/CycloneDX/cyclonedx-python-lib/actions + + + https://pypi.org/project/cyclonedx-python-lib/ + + + https://cyclonedx-python-library.readthedocs.io/ + + + https://github.com/CycloneDX/cyclonedx-python-lib/issues + + + https://github.com/CycloneDX/cyclonedx-python-lib/blob/main/LICENSE + + + https://github.com/CycloneDX/cyclonedx-python-lib/blob/main/CHANGELOG.md + + + https://github.com/CycloneDX/cyclonedx-python-lib + + + https://github.com/CycloneDX/cyclonedx-python-lib/#readme + + + test-component diff --git a/tests/_data/snapshots/get_bom_with_tools_with_component_and_service_and_tools_irreversible_migrate-1.5.json.bin b/tests/_data/snapshots/get_bom_with_tools_with_component_and_service_and_tools_irreversible_migrate-1.5.json.bin index 4c467bf6..003ad286 100644 --- a/tests/_data/snapshots/get_bom_with_tools_with_component_and_service_and_tools_irreversible_migrate-1.5.json.bin +++ b/tests/_data/snapshots/get_bom_with_tools_with_component_and_service_and_tools_irreversible_migrate-1.5.json.bin @@ -91,6 +91,45 @@ "name": "other-component", "vendor": "acme" }, + { + "externalReferences": [ + { + "type": "build-system", + "url": "https://github.com/CycloneDX/cyclonedx-python-lib/actions" + }, + { + "type": "distribution", + "url": "https://pypi.org/project/cyclonedx-python-lib/" + }, + { + "type": "documentation", + "url": "https://cyclonedx-python-library.readthedocs.io/" + }, + { + "type": "issue-tracker", + "url": "https://github.com/CycloneDX/cyclonedx-python-lib/issues" + }, + { + "type": "license", + "url": "https://github.com/CycloneDX/cyclonedx-python-lib/blob/main/LICENSE" + }, + { + "type": "release-notes", + "url": "https://github.com/CycloneDX/cyclonedx-python-lib/blob/main/CHANGELOG.md" + }, + { + "type": "vcs", + "url": "https://github.com/CycloneDX/cyclonedx-python-lib" + }, + { + "type": "website", + "url": "https://github.com/CycloneDX/cyclonedx-python-lib/#readme" + } + ], + "name": "cyclonedx-python-lib", + "vendor": "CycloneDX", + "version": "TESTING" + }, { "name": "test-component" }, diff --git a/tests/_data/snapshots/get_bom_with_tools_with_component_and_service_and_tools_irreversible_migrate-1.5.xml.bin b/tests/_data/snapshots/get_bom_with_tools_with_component_and_service_and_tools_irreversible_migrate-1.5.xml.bin index d16609a5..36269a5f 100644 --- a/tests/_data/snapshots/get_bom_with_tools_with_component_and_service_and_tools_irreversible_migrate-1.5.xml.bin +++ b/tests/_data/snapshots/get_bom_with_tools_with_component_and_service_and_tools_irreversible_migrate-1.5.xml.bin @@ -70,6 +70,37 @@ + + CycloneDX + cyclonedx-python-lib + TESTING + + + https://github.com/CycloneDX/cyclonedx-python-lib/actions + + + https://pypi.org/project/cyclonedx-python-lib/ + + + https://cyclonedx-python-library.readthedocs.io/ + + + https://github.com/CycloneDX/cyclonedx-python-lib/issues + + + https://github.com/CycloneDX/cyclonedx-python-lib/blob/main/LICENSE + + + https://github.com/CycloneDX/cyclonedx-python-lib/blob/main/CHANGELOG.md + + + https://github.com/CycloneDX/cyclonedx-python-lib + + + https://github.com/CycloneDX/cyclonedx-python-lib/#readme + + + test-component diff --git a/tests/_data/snapshots/get_bom_with_tools_with_component_and_service_and_tools_irreversible_migrate-1.6.json.bin b/tests/_data/snapshots/get_bom_with_tools_with_component_and_service_and_tools_irreversible_migrate-1.6.json.bin index 1d4d653e..9dcb98b2 100644 --- a/tests/_data/snapshots/get_bom_with_tools_with_component_and_service_and_tools_irreversible_migrate-1.6.json.bin +++ b/tests/_data/snapshots/get_bom_with_tools_with_component_and_service_and_tools_irreversible_migrate-1.6.json.bin @@ -91,6 +91,45 @@ "name": "other-component", "vendor": "acme" }, + { + "externalReferences": [ + { + "type": "build-system", + "url": "https://github.com/CycloneDX/cyclonedx-python-lib/actions" + }, + { + "type": "distribution", + "url": "https://pypi.org/project/cyclonedx-python-lib/" + }, + { + "type": "documentation", + "url": "https://cyclonedx-python-library.readthedocs.io/" + }, + { + "type": "issue-tracker", + "url": "https://github.com/CycloneDX/cyclonedx-python-lib/issues" + }, + { + "type": "license", + "url": "https://github.com/CycloneDX/cyclonedx-python-lib/blob/main/LICENSE" + }, + { + "type": "release-notes", + "url": "https://github.com/CycloneDX/cyclonedx-python-lib/blob/main/CHANGELOG.md" + }, + { + "type": "vcs", + "url": "https://github.com/CycloneDX/cyclonedx-python-lib" + }, + { + "type": "website", + "url": "https://github.com/CycloneDX/cyclonedx-python-lib/#readme" + } + ], + "name": "cyclonedx-python-lib", + "vendor": "CycloneDX", + "version": "TESTING" + }, { "name": "test-component" }, diff --git a/tests/_data/snapshots/get_bom_with_tools_with_component_and_service_and_tools_irreversible_migrate-1.6.xml.bin b/tests/_data/snapshots/get_bom_with_tools_with_component_and_service_and_tools_irreversible_migrate-1.6.xml.bin index f9b4eb19..2cef1e3c 100644 --- a/tests/_data/snapshots/get_bom_with_tools_with_component_and_service_and_tools_irreversible_migrate-1.6.xml.bin +++ b/tests/_data/snapshots/get_bom_with_tools_with_component_and_service_and_tools_irreversible_migrate-1.6.xml.bin @@ -70,6 +70,37 @@ + + CycloneDX + cyclonedx-python-lib + TESTING + + + https://github.com/CycloneDX/cyclonedx-python-lib/actions + + + https://pypi.org/project/cyclonedx-python-lib/ + + + https://cyclonedx-python-library.readthedocs.io/ + + + https://github.com/CycloneDX/cyclonedx-python-lib/issues + + + https://github.com/CycloneDX/cyclonedx-python-lib/blob/main/LICENSE + + + https://github.com/CycloneDX/cyclonedx-python-lib/blob/main/CHANGELOG.md + + + https://github.com/CycloneDX/cyclonedx-python-lib + + + https://github.com/CycloneDX/cyclonedx-python-lib/#readme + + + test-component diff --git a/tests/_data/snapshots/get_bom_with_tools_with_component_and_service_migrate-1.2.json.bin b/tests/_data/snapshots/get_bom_with_tools_with_component_and_service_migrate-1.2.json.bin index ce417066..fe7ad128 100644 --- a/tests/_data/snapshots/get_bom_with_tools_with_component_and_service_migrate-1.2.json.bin +++ b/tests/_data/snapshots/get_bom_with_tools_with_component_and_service_migrate-1.2.json.bin @@ -12,6 +12,11 @@ "name": "other-component", "vendor": "acme" }, + { + "name": "cyclonedx-python-lib", + "vendor": "CycloneDX", + "version": "TESTING" + }, { "name": "test-component" }, diff --git a/tests/_data/snapshots/get_bom_with_tools_with_component_and_service_migrate-1.2.xml.bin b/tests/_data/snapshots/get_bom_with_tools_with_component_and_service_migrate-1.2.xml.bin index 2fa064f6..127ca67d 100644 --- a/tests/_data/snapshots/get_bom_with_tools_with_component_and_service_migrate-1.2.xml.bin +++ b/tests/_data/snapshots/get_bom_with_tools_with_component_and_service_migrate-1.2.xml.bin @@ -10,6 +10,11 @@ 49b420bd8d8182542a76d4422e0c7890dcc88a3d8ddad04da06366d8c40ac8ca + + CycloneDX + cyclonedx-python-lib + TESTING + test-component diff --git a/tests/_data/snapshots/get_bom_with_tools_with_component_and_service_migrate-1.3.json.bin b/tests/_data/snapshots/get_bom_with_tools_with_component_and_service_migrate-1.3.json.bin index 6990fc8a..9a895165 100644 --- a/tests/_data/snapshots/get_bom_with_tools_with_component_and_service_migrate-1.3.json.bin +++ b/tests/_data/snapshots/get_bom_with_tools_with_component_and_service_migrate-1.3.json.bin @@ -12,6 +12,11 @@ "name": "other-component", "vendor": "acme" }, + { + "name": "cyclonedx-python-lib", + "vendor": "CycloneDX", + "version": "TESTING" + }, { "name": "test-component" }, diff --git a/tests/_data/snapshots/get_bom_with_tools_with_component_and_service_migrate-1.3.xml.bin b/tests/_data/snapshots/get_bom_with_tools_with_component_and_service_migrate-1.3.xml.bin index 4e71b908..179cd42f 100644 --- a/tests/_data/snapshots/get_bom_with_tools_with_component_and_service_migrate-1.3.xml.bin +++ b/tests/_data/snapshots/get_bom_with_tools_with_component_and_service_migrate-1.3.xml.bin @@ -10,6 +10,11 @@ 49b420bd8d8182542a76d4422e0c7890dcc88a3d8ddad04da06366d8c40ac8ca + + CycloneDX + cyclonedx-python-lib + TESTING + test-component diff --git a/tests/_data/snapshots/get_bom_with_tools_with_component_and_service_migrate-1.4.json.bin b/tests/_data/snapshots/get_bom_with_tools_with_component_and_service_migrate-1.4.json.bin index 3851eb48..0a8265dc 100644 --- a/tests/_data/snapshots/get_bom_with_tools_with_component_and_service_migrate-1.4.json.bin +++ b/tests/_data/snapshots/get_bom_with_tools_with_component_and_service_migrate-1.4.json.bin @@ -25,6 +25,45 @@ "name": "other-component", "vendor": "acme" }, + { + "externalReferences": [ + { + "type": "build-system", + "url": "https://github.com/CycloneDX/cyclonedx-python-lib/actions" + }, + { + "type": "distribution", + "url": "https://pypi.org/project/cyclonedx-python-lib/" + }, + { + "type": "documentation", + "url": "https://cyclonedx-python-library.readthedocs.io/" + }, + { + "type": "issue-tracker", + "url": "https://github.com/CycloneDX/cyclonedx-python-lib/issues" + }, + { + "type": "license", + "url": "https://github.com/CycloneDX/cyclonedx-python-lib/blob/main/LICENSE" + }, + { + "type": "release-notes", + "url": "https://github.com/CycloneDX/cyclonedx-python-lib/blob/main/CHANGELOG.md" + }, + { + "type": "vcs", + "url": "https://github.com/CycloneDX/cyclonedx-python-lib" + }, + { + "type": "website", + "url": "https://github.com/CycloneDX/cyclonedx-python-lib/#readme" + } + ], + "name": "cyclonedx-python-lib", + "vendor": "CycloneDX", + "version": "TESTING" + }, { "name": "test-component" }, diff --git a/tests/_data/snapshots/get_bom_with_tools_with_component_and_service_migrate-1.4.xml.bin b/tests/_data/snapshots/get_bom_with_tools_with_component_and_service_migrate-1.4.xml.bin index 426cdf54..37e5bb55 100644 --- a/tests/_data/snapshots/get_bom_with_tools_with_component_and_service_migrate-1.4.xml.bin +++ b/tests/_data/snapshots/get_bom_with_tools_with_component_and_service_migrate-1.4.xml.bin @@ -19,6 +19,37 @@ + + CycloneDX + cyclonedx-python-lib + TESTING + + + https://github.com/CycloneDX/cyclonedx-python-lib/actions + + + https://pypi.org/project/cyclonedx-python-lib/ + + + https://cyclonedx-python-library.readthedocs.io/ + + + https://github.com/CycloneDX/cyclonedx-python-lib/issues + + + https://github.com/CycloneDX/cyclonedx-python-lib/blob/main/LICENSE + + + https://github.com/CycloneDX/cyclonedx-python-lib/blob/main/CHANGELOG.md + + + https://github.com/CycloneDX/cyclonedx-python-lib + + + https://github.com/CycloneDX/cyclonedx-python-lib/#readme + + + test-component diff --git a/tests/_data/snapshots/get_bom_with_tools_with_component_and_service_migrate-1.5.json.bin b/tests/_data/snapshots/get_bom_with_tools_with_component_and_service_migrate-1.5.json.bin index 9b205056..f040c90a 100644 --- a/tests/_data/snapshots/get_bom_with_tools_with_component_and_service_migrate-1.5.json.bin +++ b/tests/_data/snapshots/get_bom_with_tools_with_component_and_service_migrate-1.5.json.bin @@ -28,6 +28,54 @@ "name": "other-component", "type": "application" }, + { + "description": "Python library for CycloneDX", + "externalReferences": [ + { + "type": "build-system", + "url": "https://github.com/CycloneDX/cyclonedx-python-lib/actions" + }, + { + "type": "distribution", + "url": "https://pypi.org/project/cyclonedx-python-lib/" + }, + { + "type": "documentation", + "url": "https://cyclonedx-python-library.readthedocs.io/" + }, + { + "type": "issue-tracker", + "url": "https://github.com/CycloneDX/cyclonedx-python-lib/issues" + }, + { + "type": "license", + "url": "https://github.com/CycloneDX/cyclonedx-python-lib/blob/main/LICENSE" + }, + { + "type": "release-notes", + "url": "https://github.com/CycloneDX/cyclonedx-python-lib/blob/main/CHANGELOG.md" + }, + { + "type": "vcs", + "url": "https://github.com/CycloneDX/cyclonedx-python-lib" + }, + { + "type": "website", + "url": "https://github.com/CycloneDX/cyclonedx-python-lib/#readme" + } + ], + "group": "CycloneDX", + "licenses": [ + { + "license": { + "id": "Apache-2.0" + } + } + ], + "name": "cyclonedx-python-lib", + "type": "library", + "version": "TESTING" + }, { "bom-ref": "test-component", "name": "test-component", diff --git a/tests/_data/snapshots/get_bom_with_tools_with_component_and_service_migrate-1.5.xml.bin b/tests/_data/snapshots/get_bom_with_tools_with_component_and_service_migrate-1.5.xml.bin index 66d11d3b..4a7bcd8c 100644 --- a/tests/_data/snapshots/get_bom_with_tools_with_component_and_service_migrate-1.5.xml.bin +++ b/tests/_data/snapshots/get_bom_with_tools_with_component_and_service_migrate-1.5.xml.bin @@ -20,6 +20,43 @@ + + CycloneDX + cyclonedx-python-lib + TESTING + Python library for CycloneDX + + + Apache-2.0 + + + + + https://github.com/CycloneDX/cyclonedx-python-lib/actions + + + https://pypi.org/project/cyclonedx-python-lib/ + + + https://cyclonedx-python-library.readthedocs.io/ + + + https://github.com/CycloneDX/cyclonedx-python-lib/issues + + + https://github.com/CycloneDX/cyclonedx-python-lib/blob/main/LICENSE + + + https://github.com/CycloneDX/cyclonedx-python-lib/blob/main/CHANGELOG.md + + + https://github.com/CycloneDX/cyclonedx-python-lib + + + https://github.com/CycloneDX/cyclonedx-python-lib/#readme + + + test-component diff --git a/tests/_data/snapshots/get_bom_with_tools_with_component_and_service_migrate-1.6.json.bin b/tests/_data/snapshots/get_bom_with_tools_with_component_and_service_migrate-1.6.json.bin index 7ddfb8fa..eb1ff770 100644 --- a/tests/_data/snapshots/get_bom_with_tools_with_component_and_service_migrate-1.6.json.bin +++ b/tests/_data/snapshots/get_bom_with_tools_with_component_and_service_migrate-1.6.json.bin @@ -28,6 +28,55 @@ "name": "other-component", "type": "application" }, + { + "description": "Python library for CycloneDX", + "externalReferences": [ + { + "type": "build-system", + "url": "https://github.com/CycloneDX/cyclonedx-python-lib/actions" + }, + { + "type": "distribution", + "url": "https://pypi.org/project/cyclonedx-python-lib/" + }, + { + "type": "documentation", + "url": "https://cyclonedx-python-library.readthedocs.io/" + }, + { + "type": "issue-tracker", + "url": "https://github.com/CycloneDX/cyclonedx-python-lib/issues" + }, + { + "type": "license", + "url": "https://github.com/CycloneDX/cyclonedx-python-lib/blob/main/LICENSE" + }, + { + "type": "release-notes", + "url": "https://github.com/CycloneDX/cyclonedx-python-lib/blob/main/CHANGELOG.md" + }, + { + "type": "vcs", + "url": "https://github.com/CycloneDX/cyclonedx-python-lib" + }, + { + "type": "website", + "url": "https://github.com/CycloneDX/cyclonedx-python-lib/#readme" + } + ], + "group": "CycloneDX", + "licenses": [ + { + "license": { + "acknowledgement": "declared", + "id": "Apache-2.0" + } + } + ], + "name": "cyclonedx-python-lib", + "type": "library", + "version": "TESTING" + }, { "bom-ref": "test-component", "name": "test-component", diff --git a/tests/_data/snapshots/get_bom_with_tools_with_component_and_service_migrate-1.6.xml.bin b/tests/_data/snapshots/get_bom_with_tools_with_component_and_service_migrate-1.6.xml.bin index 89519324..84aced32 100644 --- a/tests/_data/snapshots/get_bom_with_tools_with_component_and_service_migrate-1.6.xml.bin +++ b/tests/_data/snapshots/get_bom_with_tools_with_component_and_service_migrate-1.6.xml.bin @@ -20,6 +20,43 @@ + + CycloneDX + cyclonedx-python-lib + TESTING + Python library for CycloneDX + + + Apache-2.0 + + + + + https://github.com/CycloneDX/cyclonedx-python-lib/actions + + + https://pypi.org/project/cyclonedx-python-lib/ + + + https://cyclonedx-python-library.readthedocs.io/ + + + https://github.com/CycloneDX/cyclonedx-python-lib/issues + + + https://github.com/CycloneDX/cyclonedx-python-lib/blob/main/LICENSE + + + https://github.com/CycloneDX/cyclonedx-python-lib/blob/main/CHANGELOG.md + + + https://github.com/CycloneDX/cyclonedx-python-lib + + + https://github.com/CycloneDX/cyclonedx-python-lib/#readme + + + test-component diff --git a/tests/_data/snapshots/get_bom_with_tools_with_component_migrate-1.2.json.bin b/tests/_data/snapshots/get_bom_with_tools_with_component_migrate-1.2.json.bin index 254aa82a..9bd4cad8 100644 --- a/tests/_data/snapshots/get_bom_with_tools_with_component_migrate-1.2.json.bin +++ b/tests/_data/snapshots/get_bom_with_tools_with_component_migrate-1.2.json.bin @@ -12,6 +12,11 @@ "name": "other-component", "vendor": "acme" }, + { + "name": "cyclonedx-python-lib", + "vendor": "CycloneDX", + "version": "TESTING" + }, { "name": "test-component" } diff --git a/tests/_data/snapshots/get_bom_with_tools_with_component_migrate-1.2.xml.bin b/tests/_data/snapshots/get_bom_with_tools_with_component_migrate-1.2.xml.bin index e8e74ab2..5b72b038 100644 --- a/tests/_data/snapshots/get_bom_with_tools_with_component_migrate-1.2.xml.bin +++ b/tests/_data/snapshots/get_bom_with_tools_with_component_migrate-1.2.xml.bin @@ -10,6 +10,11 @@ 49b420bd8d8182542a76d4422e0c7890dcc88a3d8ddad04da06366d8c40ac8ca + + CycloneDX + cyclonedx-python-lib + TESTING + test-component diff --git a/tests/_data/snapshots/get_bom_with_tools_with_component_migrate-1.3.json.bin b/tests/_data/snapshots/get_bom_with_tools_with_component_migrate-1.3.json.bin index 7477a298..b15f1484 100644 --- a/tests/_data/snapshots/get_bom_with_tools_with_component_migrate-1.3.json.bin +++ b/tests/_data/snapshots/get_bom_with_tools_with_component_migrate-1.3.json.bin @@ -12,6 +12,11 @@ "name": "other-component", "vendor": "acme" }, + { + "name": "cyclonedx-python-lib", + "vendor": "CycloneDX", + "version": "TESTING" + }, { "name": "test-component" } diff --git a/tests/_data/snapshots/get_bom_with_tools_with_component_migrate-1.3.xml.bin b/tests/_data/snapshots/get_bom_with_tools_with_component_migrate-1.3.xml.bin index fadc64c7..9b323bdf 100644 --- a/tests/_data/snapshots/get_bom_with_tools_with_component_migrate-1.3.xml.bin +++ b/tests/_data/snapshots/get_bom_with_tools_with_component_migrate-1.3.xml.bin @@ -10,6 +10,11 @@ 49b420bd8d8182542a76d4422e0c7890dcc88a3d8ddad04da06366d8c40ac8ca + + CycloneDX + cyclonedx-python-lib + TESTING + test-component diff --git a/tests/_data/snapshots/get_bom_with_tools_with_component_migrate-1.4.json.bin b/tests/_data/snapshots/get_bom_with_tools_with_component_migrate-1.4.json.bin index 84229368..29a67eb3 100644 --- a/tests/_data/snapshots/get_bom_with_tools_with_component_migrate-1.4.json.bin +++ b/tests/_data/snapshots/get_bom_with_tools_with_component_migrate-1.4.json.bin @@ -25,6 +25,45 @@ "name": "other-component", "vendor": "acme" }, + { + "externalReferences": [ + { + "type": "build-system", + "url": "https://github.com/CycloneDX/cyclonedx-python-lib/actions" + }, + { + "type": "distribution", + "url": "https://pypi.org/project/cyclonedx-python-lib/" + }, + { + "type": "documentation", + "url": "https://cyclonedx-python-library.readthedocs.io/" + }, + { + "type": "issue-tracker", + "url": "https://github.com/CycloneDX/cyclonedx-python-lib/issues" + }, + { + "type": "license", + "url": "https://github.com/CycloneDX/cyclonedx-python-lib/blob/main/LICENSE" + }, + { + "type": "release-notes", + "url": "https://github.com/CycloneDX/cyclonedx-python-lib/blob/main/CHANGELOG.md" + }, + { + "type": "vcs", + "url": "https://github.com/CycloneDX/cyclonedx-python-lib" + }, + { + "type": "website", + "url": "https://github.com/CycloneDX/cyclonedx-python-lib/#readme" + } + ], + "name": "cyclonedx-python-lib", + "vendor": "CycloneDX", + "version": "TESTING" + }, { "name": "test-component" } diff --git a/tests/_data/snapshots/get_bom_with_tools_with_component_migrate-1.4.xml.bin b/tests/_data/snapshots/get_bom_with_tools_with_component_migrate-1.4.xml.bin index 15c7faa4..64dd255d 100644 --- a/tests/_data/snapshots/get_bom_with_tools_with_component_migrate-1.4.xml.bin +++ b/tests/_data/snapshots/get_bom_with_tools_with_component_migrate-1.4.xml.bin @@ -19,6 +19,37 @@ + + CycloneDX + cyclonedx-python-lib + TESTING + + + https://github.com/CycloneDX/cyclonedx-python-lib/actions + + + https://pypi.org/project/cyclonedx-python-lib/ + + + https://cyclonedx-python-library.readthedocs.io/ + + + https://github.com/CycloneDX/cyclonedx-python-lib/issues + + + https://github.com/CycloneDX/cyclonedx-python-lib/blob/main/LICENSE + + + https://github.com/CycloneDX/cyclonedx-python-lib/blob/main/CHANGELOG.md + + + https://github.com/CycloneDX/cyclonedx-python-lib + + + https://github.com/CycloneDX/cyclonedx-python-lib/#readme + + + test-component diff --git a/tests/_data/snapshots/get_bom_with_tools_with_component_migrate-1.5.json.bin b/tests/_data/snapshots/get_bom_with_tools_with_component_migrate-1.5.json.bin index 3eb88d3e..f89e6e2c 100644 --- a/tests/_data/snapshots/get_bom_with_tools_with_component_migrate-1.5.json.bin +++ b/tests/_data/snapshots/get_bom_with_tools_with_component_migrate-1.5.json.bin @@ -28,6 +28,54 @@ "name": "other-component", "type": "application" }, + { + "description": "Python library for CycloneDX", + "externalReferences": [ + { + "type": "build-system", + "url": "https://github.com/CycloneDX/cyclonedx-python-lib/actions" + }, + { + "type": "distribution", + "url": "https://pypi.org/project/cyclonedx-python-lib/" + }, + { + "type": "documentation", + "url": "https://cyclonedx-python-library.readthedocs.io/" + }, + { + "type": "issue-tracker", + "url": "https://github.com/CycloneDX/cyclonedx-python-lib/issues" + }, + { + "type": "license", + "url": "https://github.com/CycloneDX/cyclonedx-python-lib/blob/main/LICENSE" + }, + { + "type": "release-notes", + "url": "https://github.com/CycloneDX/cyclonedx-python-lib/blob/main/CHANGELOG.md" + }, + { + "type": "vcs", + "url": "https://github.com/CycloneDX/cyclonedx-python-lib" + }, + { + "type": "website", + "url": "https://github.com/CycloneDX/cyclonedx-python-lib/#readme" + } + ], + "group": "CycloneDX", + "licenses": [ + { + "license": { + "id": "Apache-2.0" + } + } + ], + "name": "cyclonedx-python-lib", + "type": "library", + "version": "TESTING" + }, { "bom-ref": "test-component", "name": "test-component", diff --git a/tests/_data/snapshots/get_bom_with_tools_with_component_migrate-1.5.xml.bin b/tests/_data/snapshots/get_bom_with_tools_with_component_migrate-1.5.xml.bin index 5a6ba111..aa284908 100644 --- a/tests/_data/snapshots/get_bom_with_tools_with_component_migrate-1.5.xml.bin +++ b/tests/_data/snapshots/get_bom_with_tools_with_component_migrate-1.5.xml.bin @@ -20,6 +20,43 @@ + + CycloneDX + cyclonedx-python-lib + TESTING + Python library for CycloneDX + + + Apache-2.0 + + + + + https://github.com/CycloneDX/cyclonedx-python-lib/actions + + + https://pypi.org/project/cyclonedx-python-lib/ + + + https://cyclonedx-python-library.readthedocs.io/ + + + https://github.com/CycloneDX/cyclonedx-python-lib/issues + + + https://github.com/CycloneDX/cyclonedx-python-lib/blob/main/LICENSE + + + https://github.com/CycloneDX/cyclonedx-python-lib/blob/main/CHANGELOG.md + + + https://github.com/CycloneDX/cyclonedx-python-lib + + + https://github.com/CycloneDX/cyclonedx-python-lib/#readme + + + test-component diff --git a/tests/_data/snapshots/get_bom_with_tools_with_component_migrate-1.6.json.bin b/tests/_data/snapshots/get_bom_with_tools_with_component_migrate-1.6.json.bin index 1348f4f3..dea1d9d9 100644 --- a/tests/_data/snapshots/get_bom_with_tools_with_component_migrate-1.6.json.bin +++ b/tests/_data/snapshots/get_bom_with_tools_with_component_migrate-1.6.json.bin @@ -28,6 +28,55 @@ "name": "other-component", "type": "application" }, + { + "description": "Python library for CycloneDX", + "externalReferences": [ + { + "type": "build-system", + "url": "https://github.com/CycloneDX/cyclonedx-python-lib/actions" + }, + { + "type": "distribution", + "url": "https://pypi.org/project/cyclonedx-python-lib/" + }, + { + "type": "documentation", + "url": "https://cyclonedx-python-library.readthedocs.io/" + }, + { + "type": "issue-tracker", + "url": "https://github.com/CycloneDX/cyclonedx-python-lib/issues" + }, + { + "type": "license", + "url": "https://github.com/CycloneDX/cyclonedx-python-lib/blob/main/LICENSE" + }, + { + "type": "release-notes", + "url": "https://github.com/CycloneDX/cyclonedx-python-lib/blob/main/CHANGELOG.md" + }, + { + "type": "vcs", + "url": "https://github.com/CycloneDX/cyclonedx-python-lib" + }, + { + "type": "website", + "url": "https://github.com/CycloneDX/cyclonedx-python-lib/#readme" + } + ], + "group": "CycloneDX", + "licenses": [ + { + "license": { + "acknowledgement": "declared", + "id": "Apache-2.0" + } + } + ], + "name": "cyclonedx-python-lib", + "type": "library", + "version": "TESTING" + }, { "bom-ref": "test-component", "name": "test-component", diff --git a/tests/_data/snapshots/get_bom_with_tools_with_component_migrate-1.6.xml.bin b/tests/_data/snapshots/get_bom_with_tools_with_component_migrate-1.6.xml.bin index 0963cb16..2f8ceecf 100644 --- a/tests/_data/snapshots/get_bom_with_tools_with_component_migrate-1.6.xml.bin +++ b/tests/_data/snapshots/get_bom_with_tools_with_component_migrate-1.6.xml.bin @@ -20,6 +20,43 @@ + + CycloneDX + cyclonedx-python-lib + TESTING + Python library for CycloneDX + + + Apache-2.0 + + + + + https://github.com/CycloneDX/cyclonedx-python-lib/actions + + + https://pypi.org/project/cyclonedx-python-lib/ + + + https://cyclonedx-python-library.readthedocs.io/ + + + https://github.com/CycloneDX/cyclonedx-python-lib/issues + + + https://github.com/CycloneDX/cyclonedx-python-lib/blob/main/LICENSE + + + https://github.com/CycloneDX/cyclonedx-python-lib/blob/main/CHANGELOG.md + + + https://github.com/CycloneDX/cyclonedx-python-lib + + + https://github.com/CycloneDX/cyclonedx-python-lib/#readme + + + test-component diff --git a/tests/test_deserialize_json.py b/tests/test_deserialize_json.py index 03306571..4c66a7cc 100644 --- a/tests/test_deserialize_json.py +++ b/tests/test_deserialize_json.py @@ -40,7 +40,7 @@ class TestDeserializeJson(TestCase, SnapshotMixin, DeepCompareMixin): @named_data(*all_get_bom_funct_valid_immut, *all_get_bom_funct_valid_reversible_migrate) - @patch('cyclonedx.model.ThisTool._version', 'TESTING') + @patch('cyclonedx.builder.this.__ThisVersion', 'TESTING') def test_prepared(self, get_bom: Callable[[], Bom], *_: Any, **__: Any) -> None: # only latest schema will have all data populated in serialized form snapshot_name = mksname(get_bom, SchemaVersion.V1_6, OutputFormat.JSON) diff --git a/tests/test_deserialize_xml.py b/tests/test_deserialize_xml.py index 3b02fe77..bf3bbb89 100644 --- a/tests/test_deserialize_xml.py +++ b/tests/test_deserialize_xml.py @@ -37,7 +37,7 @@ class TestDeserializeXml(TestCase, SnapshotMixin, DeepCompareMixin): @named_data(*all_get_bom_funct_valid_immut, *all_get_bom_funct_valid_reversible_migrate) - @patch('cyclonedx.model.ThisTool._version', 'TESTING') + @patch('cyclonedx.builder.this.__ThisVersion', 'TESTING') def test_prepared(self, get_bom: Callable[[], Bom], *_: Any, **__: Any) -> None: # only latest schema will have all data populated in serialized form snapshot_name = mksname(get_bom, SchemaVersion.V1_6, OutputFormat.XML) diff --git a/tests/test_enums.py b/tests/test_enums.py index ba5c6c5f..3378648a 100644 --- a/tests/test_enums.py +++ b/tests/test_enums.py @@ -19,7 +19,6 @@ from json import load as json_load from typing import Any, Generator, Iterable, Tuple, Type from unittest import TestCase -from unittest.mock import patch from warnings import warn from xml.etree.ElementTree import parse as xml_parse # nosec B405 @@ -163,7 +162,6 @@ def test_knows_value(self, value: str) -> None: super()._test_knows_value(DataFlow, value) @named_data(*NAMED_OF_SV) - @patch('cyclonedx.model.ThisTool._version', 'TESTING') def test_cases_render_valid(self, of: OutputFormat, sv: SchemaVersion, *_: Any, **__: Any) -> None: bom = _make_bom(services=[Service(name='dummy', bom_ref='dummy', data=( DataClassification(flow=df, classification=df.name) @@ -183,7 +181,6 @@ def test_knows_value(self, value: str) -> None: super()._test_knows_value(Encoding, value) @named_data(*NAMED_OF_SV) - @patch('cyclonedx.model.ThisTool._version', 'TESTING') 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'att.encoding: {encoding.name}', text=AttachedText( @@ -204,7 +201,6 @@ def test_knows_value(self, value: str) -> None: super()._test_knows_value(ExternalReferenceType, value) @named_data(*NAMED_OF_SV) - @patch('cyclonedx.model.ThisTool._version', 'TESTING') 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', external_references=( @@ -226,7 +222,6 @@ def test_knows_value(self, value: str) -> None: super()._test_knows_value(HashAlgorithm, value) @named_data(*NAMED_OF_SV) - @patch('cyclonedx.model.ThisTool._version', 'TESTING') 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', hashes=( HashType(alg=alg, content='ae2b1fca515949e5d54fb22b8ed95575') @@ -246,7 +241,6 @@ def test_knows_value(self, value: str) -> None: super()._test_knows_value(ComponentScope, value) @named_data(*NAMED_OF_SV) - @patch('cyclonedx.model.ThisTool._version', 'TESTING') def test_cases_render_valid(self, of: OutputFormat, sv: SchemaVersion, *_: Any, **__: Any) -> None: bom = _make_bom(components=( Component(bom_ref=f'scoped-{scope.name}', name=f'dummy-{scope.name}', @@ -285,7 +279,6 @@ def test_knows_value(self, value: str) -> None: super()._test_knows_value(ComponentType, value) @named_data(*NAMED_OF_SV) - @patch('cyclonedx.model.ThisTool._version', 'TESTING') def test_cases_render_valid(self, of: OutputFormat, sv: SchemaVersion, *_: Any, **__: Any) -> None: if OutputFormat.XML is of: schema_cases = set(dp_cases_from_xml_schema(SCHEMA_XML[sv], _DP_ComponentType.XML_SCHEMA_XPATH)) @@ -322,7 +315,6 @@ def test_knows_value(self, value: str) -> None: super()._test_knows_value(PatchClassification, value) @named_data(*NAMED_OF_SV) - @patch('cyclonedx.model.ThisTool._version', 'TESTING') 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', pedigree=Pedigree(patches=( @@ -344,7 +336,6 @@ def test_knows_value(self, value: str) -> None: super()._test_knows_value(ImpactAnalysisAffectedStatus, value) @named_data(*NAMED_OF_SV) - @patch('cyclonedx.model.ThisTool._version', 'TESTING') def test_cases_render_valid(self, of: OutputFormat, sv: SchemaVersion, *_: Any, **__: Any) -> None: bom = _make_bom(vulnerabilities=[Vulnerability( bom_ref='dummy', id='dummy', affects=[BomTarget(ref='urn:cdx:bom23/1#comp42', versions=( @@ -366,7 +357,6 @@ def test_knows_value(self, value: str) -> None: super()._test_knows_value(ImpactAnalysisJustification, value) @named_data(*NAMED_OF_SV) - @patch('cyclonedx.model.ThisTool._version', 'TESTING') def test_cases_render_valid(self, of: OutputFormat, sv: SchemaVersion, *_: Any, **__: Any) -> None: bom = _make_bom(vulnerabilities=( Vulnerability( @@ -389,7 +379,6 @@ def test_knows_value(self, value: str) -> None: super()._test_knows_value(ImpactAnalysisResponse, value) @named_data(*NAMED_OF_SV) - @patch('cyclonedx.model.ThisTool._version', 'TESTING') def test_cases_render_valid(self, of: OutputFormat, sv: SchemaVersion, *_: Any, **__: Any) -> None: bom = _make_bom(vulnerabilities=[Vulnerability( bom_ref='dummy', id='dummy', @@ -411,7 +400,6 @@ def test_knows_value(self, value: str) -> None: super()._test_knows_value(ImpactAnalysisState, value) @named_data(*NAMED_OF_SV) - @patch('cyclonedx.model.ThisTool._version', 'TESTING') def test_cases_render_valid(self, of: OutputFormat, sv: SchemaVersion, *_: Any, **__: Any) -> None: bom = _make_bom(vulnerabilities=( Vulnerability( @@ -433,7 +421,6 @@ def test_knows_value(self, value: str) -> None: super()._test_knows_value(IssueClassification, value) @named_data(*NAMED_OF_SV) - @patch('cyclonedx.model.ThisTool._version', 'TESTING') 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', pedigree=Pedigree(patches=[ @@ -457,7 +444,6 @@ def test_knows_value(self, value: str) -> None: super()._test_knows_value(VulnerabilityScoreSource, value) @named_data(*NAMED_OF_SV) - @patch('cyclonedx.model.ThisTool._version', 'TESTING') def test_cases_render_valid(self, of: OutputFormat, sv: SchemaVersion, *_: Any, **__: Any) -> None: bom = _make_bom(vulnerabilities=[Vulnerability(bom_ref='dummy', id='dummy', ratings=( VulnerabilityRating(method=vss) @@ -477,7 +463,6 @@ def test_knows_value(self, value: str) -> None: super()._test_knows_value(VulnerabilitySeverity, value) @named_data(*NAMED_OF_SV) - @patch('cyclonedx.model.ThisTool._version', 'TESTING') def test_cases_render_valid(self, of: OutputFormat, sv: SchemaVersion, *_: Any, **__: Any) -> None: bom = _make_bom(vulnerabilities=[Vulnerability(bom_ref='dummy', id='dummy', ratings=( VulnerabilityRating(severity=vs) diff --git a/tests/test_model_bom.py b/tests/test_model_bom.py index 045929ff..7c2cbcf3 100644 --- a/tests/test_model_bom.py +++ b/tests/test_model_bom.py @@ -23,12 +23,13 @@ from ddt import ddt, named_data from cyclonedx.exception.model import LicenseExpressionAlongWithOthersException -from cyclonedx.model import Property, ThisTool, Tool +from cyclonedx.model import Property from cyclonedx.model.bom import Bom, BomMetaData from cyclonedx.model.bom_ref import BomRef from cyclonedx.model.component import Component, ComponentType from cyclonedx.model.contact import OrganizationalContact, OrganizationalEntity from cyclonedx.model.license import DisjunctiveLicense +from cyclonedx.model.tool import Tool from tests._data.models import ( get_bom_component_licenses_invalid, get_bom_component_nested_licenses_invalid, @@ -93,7 +94,7 @@ def test_basic_bom_metadata(self) -> None: self.assertTrue(properties[0] in metadata.properties) self.assertTrue(properties[1] in metadata.properties) self.assertIsNotNone(metadata.tools) - self.assertTrue(ThisTool not in metadata.tools.tools) + self.assertEqual(2, len(metadata.tools.tools)) self.assertTrue(tools[0] in metadata.tools.tools) self.assertTrue(tools[1] in metadata.tools.tools) @@ -101,11 +102,6 @@ def test_basic_bom_metadata(self) -> None: @ddt class TestBom(TestCase): - def test_bom_metadata_tool_this_tool(self) -> None: - self.assertEqual(ThisTool.vendor, 'CycloneDX') - self.assertEqual(ThisTool.name, 'cyclonedx-python-lib') - self.assertNotEqual(ThisTool.version, 'UNKNOWN') - def test_bom_metadata_tool_multiple_tools(self) -> None: bom = Bom() self.assertEqual(len(bom.metadata.tools), 0) diff --git a/tests/test_output_json.py b/tests/test_output_json.py index 1c9509a3..eb610041 100644 --- a/tests/test_output_json.py +++ b/tests/test_output_json.py @@ -61,7 +61,7 @@ def test_unsupported_schema_raises(self, sv: SchemaVersion) -> None: and is_valid_for_schema_version(gb, sv) )) @unpack - @patch('cyclonedx.model.ThisTool._version', 'TESTING') + @patch('cyclonedx.builder.this.__ThisVersion', 'TESTING') def test_valid(self, get_bom: Callable[[], Bom], sv: SchemaVersion, *_: Any, **__: Any) -> None: snapshot_name = mksname(get_bom, sv, OutputFormat.JSON) bom = get_bom() diff --git a/tests/test_output_xml.py b/tests/test_output_xml.py index fd5ff365..26736606 100644 --- a/tests/test_output_xml.py +++ b/tests/test_output_xml.py @@ -48,7 +48,7 @@ class TestOutputXml(TestCase, SnapshotMixin): if is_valid_for_schema_version(gb, sv) )) @unpack - @patch('cyclonedx.model.ThisTool._version', 'TESTING') + @patch('cyclonedx.builder.this.__ThisVersion', 'TESTING') def test_valid(self, get_bom: Callable[[], Bom], sv: SchemaVersion, *_: Any, **__: Any) -> None: snapshot_name = mksname(get_bom, sv, OutputFormat.XML) if snapshot_name is None: diff --git a/tests/test_real_world_examples.py b/tests/test_real_world_examples.py index cc60bf9b..93cd5636 100644 --- a/tests/test_real_world_examples.py +++ b/tests/test_real_world_examples.py @@ -25,7 +25,7 @@ from tests import OWN_DATA_DIRECTORY -@patch('cyclonedx.model.ThisTool._version', 'TESTING') +@patch('cyclonedx.builder.this.__ThisVersion', 'TESTING') @patch('cyclonedx.model.bom._get_now_utc', return_value=datetime.fromisoformat('2023-01-07 13:44:32.312678+00:00')) class TestDeserializeRealWorldExamples(unittest.TestCase):