Skip to content

Generate SBOM and Scan Vulnerabilities

Generates the SBOM of a directory, in CycloneDX format, and scans its components for known vulnerabilities in OSV.dev. Put it in a job rule after the checkout or the build, on the job directory: the report is stored in Clarive, the CycloneDX document and the list of vulnerabilities are attached to the job log, and the job can fail when the scan finds vulnerabilities of a given severity.

Parameters

Parameter Description
Path Directory (or a single manifest file) to analyze. Defaults to ${job_dir}
Technology All (detect) reads every technology found in the tree. Pick one to read only its files
Excluded Directories Directory names to skip, besides the usual ones (node_modules, vendor, .git...), comma separated
Private Packages Patterns of packages never sent to OSV, one per line, added to the global and project ones. See private packages
Application Name Name of the application in the SBOM. Defaults to the job name
Version Version of the application in the SBOM
Scan components for known vulnerabilities Uncheck it to generate the SBOM only
Fail Job on Severity Fails the job when the scan finds vulnerabilities of this severity or higher. Never by default
Output File Writes the CycloneDX JSON document to this file, for instance to publish it with the release

Behavior

  1. Walks the directory tree and reads the manifests, lockfiles and binary packages of every supported technology.
  2. Stores the SBOM report and its components in Clarive, in the projects of the job. The previous report of the same application becomes superseded.
  3. Scans the components with an exact version against OSV.dev. Findings acknowledged or suppressed in the previous reports of the application keep their status.
  4. Writes to the job log the components found, with the CycloneDX document attached (sbom-cyclonedx.json), and the vulnerabilities by severity, with their list attached (vulnerabilities.txt).
  5. Fails the job if there are vulnerabilities, not suppressed, at the Fail Job on Severity level or higher.

The events event.sbom.generated and event.sbom.scan_complete fire after the generation and the scan.

Return Value

The op returns a hash:

  • mid -- the id of the SBOM report.
  • component_count -- the number of components found.
  • ecosystems -- the technologies found (npm, Maven, NuGet...).
  • vuln_count -- the number of vulnerabilities found.
  • by_severity -- the vulnerabilities not suppressed by severity, like { CRITICAL => 1, HIGH => 4 }.

Rulebook

In a rulebook, the op is sbom. Without path it analyzes the job directory:

build:
   do:
      - npm ci
      - sbom:
          fail_on: CRITICAL
      - sbom:
          path: ${job_dir}/front
          ecosystem: npm
          output_file: ${job_dir}/sbom.json