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 16, 2024
1 parent c72d5f4 commit 1c78d0b
Show file tree
Hide file tree
Showing 4 changed files with 785 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 @@ -317,6 +318,7 @@ def __init__(
dependencies: Optional[Iterable[Dependency]] = None,
vulnerabilities: Optional[Iterable[Vulnerability]] = None,
properties: Optional[Iterable[Property]] = None,
definitions: Optional[DefinitionRepository] = None,
) -> None:
"""
Create a new Bom that you can manually/programmatically add data to later.
Expand All @@ -333,6 +335,7 @@ def __init__(
self.vulnerabilities = vulnerabilities or [] # type:ignore[assignment]
self.dependencies = dependencies or [] # type:ignore[assignment]
self.properties = properties or [] # type:ignore[assignment]
self.definitions = definitions or DefinitionRepository()

@property
@serializable.type_mapping(UrnUuidHelper)
Expand Down Expand Up @@ -520,6 +523,23 @@ def vulnerabilities(self) -> 'SortedSet[Vulnerability]':
def vulnerabilities(self, vulnerabilities: Iterable[Vulnerability]) -> None:
self._vulnerabilities = SortedSet(vulnerabilities)

@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

# @property
# ...
# @serializable.view(SchemaVersion1Dot5)
Expand Down
Loading

0 comments on commit 1c78d0b

Please sign in to comment.