Skip to main content

Goal

A release does not change after you ship it, but the list of known vulnerabilities in its components does. New advisories come out every day. This recipe takes the inventory you stored at release time, refreshes its vulnerability and licence data every week, and reports the advisories that are new since the last run.

When to use it

  • You ship releases that customers run for months or years, and you must know when a new vulnerability affects one of them.
  • You keep the inventory or SBOM from each release (for example, from the release SBOM recipe).
  • The job that runs the refresh may not have the source code. enrich does not need it.

How enrich works

scanoss-cli enrich reads an existing inventory or SBOM, looks up each component by its PURL through the SCANOSS API, and writes the file again with fresh data. It does not fingerprint or scan anything, so it is quick, and you can run it as often as you like on the same file. Choose the layers with --include: vulns, licenses, crypto, and geo. Use -f, --format to write a different format in the same pass.

Prerequisites

  • scanoss-cli, jq, and SCANOSS_API_KEY (see Recipes)
  • A stored inventory, for example inventory-2.4.0.json from a release
  • A scheduler: your CI system’s scheduled pipelines, or cron

The script

Save this as ci/scanoss-refresh.sh.
Run it every week against the latest refresh, so each run reports only what is new since the week before:
Store each refreshed file where the next run can find it, for example in the same artefact store as the release.

What each step does

  1. Refresh. enrich replaces the vulnerability and licence data of every component with the current data. It does not change the components or their evidence. If a lookup fails, enrich still writes a file and exits 0, but prints a warning on stderr: Enrichment incomplete when a whole layer failed, or layer returned no data for some components when part of it failed. The script treats both as a failure, so you never compare against partial data.
  2. Compare. jq reads the previous file with --slurpfile and lists every advisory ID in the new file that the previous file did not have.
  3. Gate. Only new advisories at or above FAIL_ON_SEVERITY fail the job. Known advisories, which you have already seen, do not fail it again.

What the output means

Each line lists the advisory ID, its severity, and the affected components of that release. Use it to decide whether to ship a patch release. To see every advisory that affects the release, not only the new ones, run the licence and vulnerability gate on the refreshed file.

How it fails the pipeline

Schedule it

Any scheduler works. With cron, on a machine that has the files and the key:
In a CI system, use its scheduled pipelines and loop over the releases you still support.

Refresh an SBOM instead of the raw inventory

enrich also reads CycloneDX and SPDX files, and the comparison above works on raw files. For a CycloneDX SBOM, refresh it in place:
SPDX 2.3 cannot hold vulnerabilities, so enrich skips the vulns layer for SPDX output and prints a notice. To get vulnerability data for a release you only have as SPDX, write CycloneDX in the same pass:
enrich cannot add the deps layer, because declared dependencies come from manifest files in the source tree. Include deps when you first scan the release, as the release SBOM recipe does.