Skip to content

Commit aa33a7a

Browse files
authored
fix(sbom): correctly handle multiple vendors (intel#4857)
Prepend vendor to product to set the SBOM package name, otherwise SBOM will only contain the last vendor of the product. For example for iperf3, SBOM will only contain cpe:/a:iperf3_project:iperf3:3.11 and not cpe:/a:es:iperf3:3.11 Signed-off-by: Fabrice Fontaine <[email protected]>
1 parent 0dc9e4e commit aa33a7a

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

cve_bin_tool/sbom_manager/generate.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,9 @@ def generate_sbom(self) -> None:
7272
# Add dependent products
7373
for product_data in self.all_product_data:
7474
my_package.initialise()
75-
my_package.set_name(product_data.product)
75+
# vendor prepended to product to handle product with multiple vendors
76+
package_name = f"{product_data.vendor}-{product_data.product}"
77+
my_package.set_name(package_name)
7678
my_package.set_version(product_data.version)
7779
if product_data.vendor.casefold() != "UNKNOWN".casefold():
7880
my_package.set_supplier("Organization", product_data.vendor)
@@ -90,9 +92,7 @@ def generate_sbom(self) -> None:
9092
(my_package.get_name(), my_package.get_value("version"))
9193
] = my_package.get_package()
9294
sbom_relationship.initialise()
93-
sbom_relationship.set_relationship(
94-
root_package, "DEPENDS_ON", product_data.product
95-
)
95+
sbom_relationship.set_relationship(root_package, "DEPENDS_ON", package_name)
9696
sbom_relationships.append(sbom_relationship.get_relationship())
9797

9898
# Generate SBOM

test/test_output_engine.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -984,7 +984,8 @@ def test_generate_sbom(self):
984984

985985
# Check if set_name is called for each product
986986
expected_calls = [
987-
call(product.product) for product in self.all_product_data
987+
call(f"{product.vendor}-{product.product}")
988+
for product in self.all_product_data
988989
]
989990
mock_package_instance.set_name.assert_has_calls(
990991
expected_calls, any_order=True

0 commit comments

Comments
 (0)