Skip to content

Commit

Permalink
Include CVE patch info in cdx output
Browse files Browse the repository at this point in the history
This is helpful when the SBOM is used in vulnerability scanner
software down the line, so it is more easily obvious that these
CVEs have already been patched in this case.

Signed-off-by: Arnout Engelen <[email protected]>
  • Loading branch information
raboof authored and henrirosten committed Dec 27, 2023
1 parent 9e5ca03 commit 31f17d1
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/sbomnix/sbomdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,26 @@ def _drv_to_cdx_component(drv, uid="store_path"):
if "meta_description" in drv._asdict() and drv.meta_description:
component["description"] = drv.meta_description
_cdx_component_add_licenses(component, drv)
if drv.patches:
security_patches = []
for p in drv.patches.split(" "):
m = re.search(r"CVE-\d{4}-\d+", p, re.IGNORECASE)
if m:
patch = {
"type": "unofficial",
"resolves": [
{
"type": "security",
"id": m.group(0).upper(),
"references": [f"file://{p}"],
}
],
}
security_patches.append(patch)
if security_patches:
pedigree = {}
pedigree["patches"] = security_patches
component["pedigree"] = pedigree
properties = []
for output_path in drv.outputs:
prop = {}
Expand Down

0 comments on commit 31f17d1

Please sign in to comment.