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