Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 26 additions & 12 deletions cyclonedx/model/bom.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#
# SPDX-License-Identifier: Apache-2.0
# Copyright (c) OWASP Foundation. All Rights Reserved.
# Copyright (C) Siemens 2026. All Rights Reserved.

@jkowalleck jkowalleck Nov 23, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

# Copyright (C) Siemens 2026. All Rights Reserved.

nope. not gonna change any copyrigh



from collections.abc import Generator, Iterable
Expand Down Expand Up @@ -45,6 +46,7 @@
from . import _BOM_LINK_PREFIX, ExternalReference, Property
from .bom_ref import BomRef
from .component import Component
from .composition import Composition
from .contact import OrganizationalContact, OrganizationalEntity
from .definition import Definitions
from .dependency import Dependable, Dependency
Expand Down Expand Up @@ -444,6 +446,7 @@ def __init__(
vulnerabilities: Optional[Iterable[Vulnerability]] = None,
properties: Optional[Iterable[Property]] = None,
definitions: Optional[Definitions] = None,
compositions: Optional[Iterable[Composition]] = None,
) -> None:
"""
Create a new Bom that you can manually/programmatically add data to later.
Expand All @@ -461,6 +464,7 @@ def __init__(
self.dependencies = dependencies or []
self.properties = properties or []
self.definitions = definitions or Definitions()
self.compositions = compositions or []

@property
@serializable.type_mapping(UrnUuidHelper)
Expand Down Expand Up @@ -598,18 +602,27 @@ def dependencies(self) -> 'SortedSet[Dependency]':
def dependencies(self, dependencies: Iterable[Dependency]) -> None:
self._dependencies = SortedSet(dependencies)

# @property
# ...
# @serializable.view(SchemaVersion1Dot3)
# @serializable.view(SchemaVersion1Dot4)
# @serializable.view(SchemaVersion1Dot5)
# @serializable.xml_sequence(6)
# def compositions(self) -> ...:
# ... # TODO Since CDX 1.3
#
# @compositions.setter
# def compositions(self, ...) -> None:
# ... # TODO Since CDX 1.3
@property
@serializable.view(SchemaVersion1Dot3)
@serializable.view(SchemaVersion1Dot4)
@serializable.view(SchemaVersion1Dot5)
@serializable.view(SchemaVersion1Dot6)
@serializable.view(SchemaVersion1Dot7)
@serializable.xml_array(serializable.XmlArraySerializationType.NESTED, 'composition')
@serializable.xml_sequence(60)
def compositions(self) -> 'SortedSet[Composition]':
"""
A list of compositions that describe constituent parts (including components, services, and dependency
relationships) and their completeness.

Returns:
Set of `Composition`
"""
return self._compositions

@compositions.setter
def compositions(self, compositions: Iterable[Composition]) -> None:
self._compositions = SortedSet(compositions)

@property
# @serializable.view(SchemaVersion1Dot3) @todo: Update py-serializable to support view by OutputFormat filtering
Expand Down Expand Up @@ -873,6 +886,7 @@ def __comparable_tuple(self) -> _ComparableTuple:
_ComparableTuple(self.external_references), _ComparableTuple(
self.dependencies), _ComparableTuple(self.properties),
_ComparableTuple(self.vulnerabilities),
_ComparableTuple(self.compositions),
))

def __eq__(self, other: object) -> bool:
Expand Down
Loading