CycloneDX / cyclonedx-python-lib

Python implementation of OWASP CycloneDX
https://cyclonedx.org/
Apache License 2.0
70 stars 40 forks source link

feat: add helper method to generate`BomLink` #726

Closed saquibsaifee closed 3 weeks ago

saquibsaifee commented 3 weeks ago

Improve the process of creating and validating BOM-Link URIs within XsUri. This enhancement would standardize BOM-Link creation within XsUri, reduce potential errors in URI formation, and simplify BOM-Link validation.

from @jkowalleck

A possible solution could be something like a classmethod XsUri.make_BomLink(cls, serialnumber: Union[UUID, string], version: int = 1, bom_ref: Optional[Union[string, BomRef]] = None) -> XsUri

And we would, of course, add a method XsUri.is_BomLink(self) -> bool

jkowalleck commented 3 weeks ago

@saquibsaifee , is this feature something you would contribute?

saquibsaifee commented 3 weeks ago

Yes, I am giving it a try as we speak

jkowalleck commented 3 weeks ago

we already have parts ofg the bom-link patetrn here: https://github.com/CycloneDX/cyclonedx-python-lib/blob/70cf9b4a17abdbfc4874c3ddbefa751eb32547c4/cyclonedx/model/bom.py#L646-L647 maybe you could refactor that to urn:cdx:%s/%u and reuse it then?
or maybe not, ... whatever suites you.

saquibsaifee commented 3 weeks ago

Not able to link the PR, so mentioning it here. #728

@jkowalleck what are your thoughts on the PR?