Skip to content

Commit

Permalink
Classify cdx component type file
Browse files Browse the repository at this point in the history
Signed-off-by: Henri Rosten <[email protected]>
  • Loading branch information
henrirosten committed Jan 8, 2025
1 parent 247ff42 commit 693e1cc
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/sbomnix/cdx.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,14 @@ 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
# and out-path matches the below pattern
component["type"] = "library"
if not drv.version:
if drv.out and re.search(r"(\.tar\.|\?|\.[a-z]+$)", drv.out):
component["type"] = "file"
component["bom-ref"] = getattr(drv, uid)
component["name"] = drv.pname
component["version"] = drv.version
Expand Down

0 comments on commit 693e1cc

Please sign in to comment.