Skip to content

Commit ff93c59

Browse files
committed
feat: add bom.definitions
for CycloneDX#697 Signed-off-by: Hakan Dilek <[email protected]>
1 parent ced6d69 commit ff93c59

File tree

3 files changed

+581
-0
lines changed

3 files changed

+581
-0
lines changed

cyclonedx/model/bom.py

+20
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
from .bom_ref import BomRef
4242
from .component import Component
4343
from .contact import OrganizationalContact, OrganizationalEntity
44+
from .definition import DefinitionRepository, _DefinitionRepositoryHelper
4445
from .dependency import Dependable, Dependency
4546
from .license import License, LicenseExpression, LicenseRepository
4647
from .service import Service
@@ -71,6 +72,7 @@ def __init__(
7172
manufacturer: Optional[OrganizationalEntity] = None,
7273
# Deprecated as of v1.6
7374
manufacture: Optional[OrganizationalEntity] = None,
75+
definitions: Optional[DefinitionRepository] = None,
7476
) -> None:
7577
self.timestamp = timestamp or _get_now_utc()
7678
self.tools = tools or [] # type:ignore[assignment]
@@ -87,6 +89,7 @@ def __init__(
8789
'`bom.metadata.manufacture` is deprecated from CycloneDX v1.6 onwards. '
8890
'Please use `bom.metadata.component.manufacturer` instead.',
8991
DeprecationWarning)
92+
self.definitions = definitions
9093

9194
if not tools:
9295
self.tools.add(ThisTool)
@@ -284,6 +287,23 @@ def properties(self) -> 'SortedSet[Property]':
284287
def properties(self, properties: Iterable[Property]) -> None:
285288
self._properties = SortedSet(properties)
286289

290+
@property
291+
@serializable.type_mapping(_DefinitionRepositoryHelper)
292+
@serializable.view(SchemaVersion1Dot6)
293+
@serializable.xml_sequence(90)
294+
def definitions(self) -> Optional[DefinitionRepository]:
295+
"""
296+
The repository for definitions
297+
298+
Returns:
299+
`DefinitionRepository`
300+
"""
301+
return self._definitions
302+
303+
@definitions.setter
304+
def definitions(self, definitions: DefinitionRepository) -> None:
305+
self._definitions = definitions
306+
287307
def __eq__(self, other: object) -> bool:
288308
if isinstance(other, BomMetaData):
289309
return hash(other) == hash(self)

0 commit comments

Comments
 (0)