Description
This is version 6.4.0
Components with unique bom_refs, but the same name, will generate an error when trying to render a dependency tree. Given this script:
#!/usr/bin/env python3
from cyclonedx.model.bom import Bom
from cyclonedx.model.component import Component, ComponentType
from cyclonedx.output.json import JsonV1Dot5
bom = Bom()
bom.metadata.component = root_component = Component(
name='myApp',
type=ComponentType.APPLICATION,
bom_ref="myApp"
)
component1 = Component(
type=ComponentType.LIBRARY,
name='some-component',
bom_ref="some-component"
)
bom.components.add(component1)
bom.register_dependency(root_component, [component1])
component2 = Component(
type=ComponentType.LIBRARY,
name='some-library',
bom_ref="some-library1"
)
bom.components.add(component2)
bom.register_dependency(component1, [component2])
component3 = Component(
type=ComponentType.LIBRARY,
name='some-library',
bom_ref="some-library2"
)
bom.components.add(component3)
bom.register_dependency(component1, [component3])
print(JsonV1Dot5(bom).output_as_string(indent=2))
I get this error when I run it:
Traceback (most recent call last):
File "/Users/tek30584/programming/cdx_lib_bugs/./duplicate_name_bug.py", line 38, in <module>
print(JsonV1Dot5(bom).output_as_string(indent=2))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/tek30584/programming/cdx_lib_bugs/.venv/lib/python3.11/site-packages/cyclonedx/output/json.py", line 82, in output_as_string
self.generate()
File "/Users/tek30584/programming/cdx_lib_bugs/.venv/lib/python3.11/site-packages/cyclonedx/output/json.py", line 70, in generate
bom.validate()
File "/Users/tek30584/programming/cdx_lib_bugs/.venv/lib/python3.11/site-packages/cyclonedx/model/bom.py", line 600, in validate
raise UnknownComponentDependencyException(
cyclonedx.exception.model.UnknownComponentDependencyException: One or more Components have Dependency references to Components/Services that are not known in this BOM. They are: {<BomRef 'some-library2'>}
Metadata
Metadata
Assignees
Labels
No labels