Skip to content

Commit

Permalink
feat: add bom.definitions
Browse files Browse the repository at this point in the history
for #697

Signed-off-by: Hakan Dilek <hakandilek@gmail.com>
  • Loading branch information
hakandilek committed Oct 15, 2024
1 parent c72d5f4 commit 1d9d60d
Show file tree
Hide file tree
Showing 3 changed files with 581 additions and 0 deletions.
20 changes: 20 additions & 0 deletions cyclonedx/model/bom.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
from .bom_ref import BomRef
from .component import Component
from .contact import OrganizationalContact, OrganizationalEntity
from .definition import DefinitionRepository, _DefinitionRepositoryHelper
from .dependency import Dependable, Dependency
from .license import License, LicenseExpression, LicenseRepository
from .service import Service
Expand Down Expand Up @@ -72,6 +73,7 @@ def __init__(
manufacturer: Optional[OrganizationalEntity] = None,
# Deprecated as of v1.6
manufacture: Optional[OrganizationalEntity] = None,
definitions: Optional[DefinitionRepository] = None,
) -> None:
self.timestamp = timestamp or _get_now_utc()
self.tools = tools or [] # type:ignore[assignment]
Expand All @@ -88,6 +90,7 @@ def __init__(
'`bom.metadata.manufacture` is deprecated from CycloneDX v1.6 onwards. '
'Please use `bom.metadata.component.manufacturer` instead.',
DeprecationWarning)
self.definitions = definitions

@property
@serializable.type_mapping(serializable.helpers.XsdDateTime)
Expand Down Expand Up @@ -282,6 +285,23 @@ def properties(self) -> 'SortedSet[Property]':
def properties(self, properties: Iterable[Property]) -> None:
self._properties = SortedSet(properties)

@property
@serializable.type_mapping(_DefinitionRepositoryHelper)
@serializable.view(SchemaVersion1Dot6)
@serializable.xml_sequence(90)
def definitions(self) -> Optional[DefinitionRepository]:
"""
The repository for definitions
Returns:
`DefinitionRepository`
"""
return self._definitions

@definitions.setter
def definitions(self, definitions: DefinitionRepository) -> None:
self._definitions = definitions

def __eq__(self, other: object) -> bool:
if isinstance(other, BomMetaData):
return hash(other) == hash(self)
Expand Down
Loading

0 comments on commit 1d9d60d

Please sign in to comment.