Skip to content

Commit b16e260

Browse files
author
Saquib Saifee
committed
feat: add helper method to generate bom_link
Signed-off-by: Saquib Saifee <[email protected]>
1 parent c5efc8c commit b16e260

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

cyclonedx/model/bom.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
SchemaVersion1Dot6,
3838
)
3939
from ..serialization import LicenseRepositoryHelper, UrnUuidHelper
40-
from . import ExternalReference, Property
40+
from . import ExternalReference, Property, XsUri
4141
from .bom_ref import BomRef
4242
from .component import Component
4343
from .contact import OrganizationalContact, OrganizationalEntity
@@ -665,6 +665,21 @@ def register_dependency(self, target: Dependable, depends_on: Optional[Iterable[
665665
def urn(self) -> str:
666666
return f'urn:cdx:{self.serial_number}/{self.version}'
667667

668+
def get_bom_link(self, bom_ref: Union[str, BomRef]) -> 'XsUri':
669+
"""
670+
Generate a BOM-Link URI.
671+
672+
Args:
673+
bom_ref: The unique identifier of the component, service, or vulnerability within the BOM.
674+
675+
Returns:
676+
XsUri: Instance of XsUri with the generated BOM-Link URI.
677+
678+
.. note:
679+
See the CycloneDX Schema for BOM-Link: https://cyclonedx.org/capabilities/bomlink
680+
"""
681+
return XsUri(f'{self.urn}#{bom_ref}')
682+
668683
def validate(self) -> bool:
669684
"""
670685
Perform data-model level validations to make sure we have some known data integrity prior to attempting output

0 commit comments

Comments
 (0)