diff --git a/cyclonedx/model/bom.py b/cyclonedx/model/bom.py index ee649366..4d030169 100644 --- a/cyclonedx/model/bom.py +++ b/cyclonedx/model/bom.py @@ -87,13 +87,8 @@ def __init__( self.properties = properties or [] self.manufacturer = manufacturer self.lifecycles = lifecycles or [] - + # deprecated properties below self.manufacture = manufacture - if manufacture: - warn( - '`bom.metadata.manufacture` is deprecated from CycloneDX v1.6 onwards. ' - 'Please use `bom.metadata.component.manufacturer` instead.', - DeprecationWarning) @property @serializable.type_mapping(serializable.helpers.XsdDateTime) @@ -214,6 +209,11 @@ def manufacture(self, manufacture: Optional[OrganizationalEntity]) -> None: @todo Based on https://github.com/CycloneDX/specification/issues/346, we should set this data on `.component.manufacturer`. """ + if manufacture is not None: + warn( + '`bom.metadata.manufacture` is deprecated from CycloneDX v1.6 onwards. ' + 'Please use `bom.metadata.component.manufacturer` instead.', + DeprecationWarning) self._manufacture = manufacture @property diff --git a/cyclonedx/model/component.py b/cyclonedx/model/component.py index b0e24005..6737b39e 100644 --- a/cyclonedx/model/component.py +++ b/cyclonedx/model/component.py @@ -1010,11 +1010,9 @@ def __init__( self.supplier = supplier self.manufacturer = manufacturer self.authors = authors or [] - self.author = author self.publisher = publisher self.group = group self.name = name - self.version = version self.description = description self.scope = scope self.hashes = hashes or [] @@ -1025,7 +1023,6 @@ def __init__( self.omnibor_ids = omnibor_ids or [] self.swhids = swhids or [] self.swid = swid - self.modified = modified self.pedigree = pedigree self.external_references = external_references or [] self.properties = properties or [] @@ -1034,13 +1031,10 @@ def __init__( self.release_notes = release_notes self.crypto_properties = crypto_properties self.tags = tags or [] - - if modified: - warn('`.component.modified` is deprecated from CycloneDX v1.3 onwards. ' - 'Please use `@.pedigree` instead.', DeprecationWarning) - if author: - warn('`.component.author` is deprecated from CycloneDX v1.6 onwards. ' - 'Please use `@.authors` or `@.manufacturer` instead.', DeprecationWarning) + # spec-deprecated properties below + self.author = author + self.modified = modified + self.version = version @property @serializable.type_mapping(_ComponentTypeSerializationHelper) @@ -1175,6 +1169,9 @@ def author(self) -> Optional[str]: @author.setter def author(self, author: Optional[str]) -> None: + if author is not None: + warn('`@.author` is deprecated from CycloneDX v1.6 onwards. ' + 'Please use `@.authors` or `@.manufacturer` instead.', DeprecationWarning) self._author = author @property @@ -1255,7 +1252,7 @@ def version(self) -> Optional[str]: @version.setter def version(self, version: Optional[str]) -> None: if version and len(version) > 1024: - warn('`.component.version`has a maximum length of 1024 from CycloneDX v1.6 onwards.', UserWarning) + warn('`@.version`has a maximum length of 1024 from CycloneDX v1.6 onwards.', UserWarning) self._version = version @property @@ -1450,6 +1447,9 @@ def modified(self) -> bool: @modified.setter def modified(self, modified: bool) -> None: + if modified: + warn('`@.modified` is deprecated from CycloneDX v1.3 onwards. ' + 'Please use `@.pedigree` instead.', DeprecationWarning) self._modified = modified @property diff --git a/cyclonedx/model/tool.py b/cyclonedx/model/tool.py index 6b56057f..904cd78b 100644 --- a/cyclonedx/model/tool.py +++ b/cyclonedx/model/tool.py @@ -203,12 +203,9 @@ def __init__( # Deprecated since v1.5 tools: Optional[Iterable[Tool]] = None ) -> None: - if tools: - warn('`@.tools` is deprecated from CycloneDX v1.5 onwards. ' - 'Please use `@.components` and `@.services` instead.', - DeprecationWarning) self.components = components or () self.services = services or () + # spec-deprecated properties below self.tools = tools or () @property @@ -241,6 +238,10 @@ def tools(self) -> 'SortedSet[Tool]': @tools.setter def tools(self, tools: Iterable[Tool]) -> None: + if tools: + warn('`@.tools` is deprecated from CycloneDX v1.5 onwards. ' + 'Please use `@.components` and `@.services` instead.', + DeprecationWarning) self._tools = SortedSet(tools) def __len__(self) -> int: