From 584988e59a37a67b0f709315cef4e7bb1a8bb747 Mon Sep 17 00:00:00 2001 From: Henri Rosten Date: Sun, 22 Dec 2024 08:52:20 +0200 Subject: [PATCH] Classify cdx component type file Signed-off-by: Henri Rosten --- src/sbomnix/cdx.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/sbomnix/cdx.py b/src/sbomnix/cdx.py index 82eed04..3bade7e 100644 --- a/src/sbomnix/cdx.py +++ b/src/sbomnix/cdx.py @@ -83,7 +83,12 @@ def _cdx_component_add_patches(component, drv): def _drv_to_cdx_component(drv, uid="store_path"): """Convert one entry from sbomdb (drv) to cdx component""" component = {} + # Set the cdx component type based on the following heuristic: + # - Set the default component type to 'library' + # - Set the component type to 'file' if the drv version string is missing component["type"] = "library" + if not drv.version: + component["type"] = "file" component["bom-ref"] = getattr(drv, uid) component["name"] = drv.pname component["version"] = drv.version