Read SBOMs of other generators at the default location

What does this MR do and why?

This MR lists each library component of an SBOM that no GitLab analyzer wrote, other than an operating system package, at the default location 3rd Party Input File Path Unknown. Some generators record no usable file for a package: cyclonedx-maven-plugin and osv-scanner record none, and cyclonedx-npm records an install path. Every package therefore needs a fallback path, and later MRs read the real file where a generator records one. This MR reads an SBOM this way only when its header records no GitLab property, not only when it misses gitlab:dependency_scanning:input_file:path, so GitLab's container scanning and registry scanning SBOMs, with or without an image tag, are parsed as on master.

  • Gitlab::Ci::Parsers::Sbom::Normalizer runs after schema validation and returns one entry for each component, holding the component data and its path, which is the default location in this MR.
    • An operating system package (apk, deb, rpm, cbl-mariner, wolfi) gets no path, so it has no source and no path, as on master.
  • The parser reads such an SBOM through the normalizer when the report has third-party SBOM support, with its own loop that skips an invalid package URL as master's loop does.
    • It logs one line for each report with the number of components that it leaves out for each reason, because the component is not a library or its package URL type is not supported.
  • Sbom::CreateVulnerabilitiesService no longer adds "Required GitLab CycloneDX properties are missing" to the "Error parsing SBOM reports" alert for a report with third-party SBOM support whose SBOM header records no GitLab property.
    • An SBOM that records some GitLab properties but misses a required one keeps the alert.

This MR is the second of 8 in a stack. The next one is Read a framework component of a third-party SBO... (!264252 - merged) • Igor Frenkel • 19.6.

Example

A component of a Trivy 0.74.0 SBOM of a Maven project (trimmed): a Maven library with no property that names a file.

{
  "type": "library",
  "name": "commons-io",
  "version": "2.4",
  "purl": "pkg:maven/commons-io/commons-io@2.4"
}
  • Before this MR: the SBOM gives 11 rows, each with no path (the GraphQL location.path is null).
  • After this MR: the same 11 rows, each at 3rd Party Input File Path Unknown.
  • GitLab's own SBOM of the same project is unchanged: core/pom.xml has 5 rows and foo/pom.xml has 9 rows.

References

Screenshots or screen recordings

No UI change.

How to set up and validate locally

  1. In a Rails console on a development instance run Feature.enable(:third_party_sbom_support).
  2. Create a project, add an SBOM of one of the kinds below and a .gitlab-ci.yml job that uploads it as artifacts:reports:cyclonedx, and run the pipeline.
  3. Open the Dependency List and read the location of each row, or the dependencies GraphQL field (name, version, packager, location { path }). Observed:
    • An SBOM that records no file for its packages: 3 rows at 3rd Party Input File Path Unknown (commons-io, lodash, log4j-core).
      • The framework component commons-text is not a row.
      • The pipeline shows no "Error parsing SBOM reports" alert.
    • A Trivy SBOM of a multi-module Maven project: 11 rows at the same path.
    • A Trivy SBOM of a container image: accepts and commons-collections at the same path, and the operating system package musl with no path.
    • An SBOM with a component whose version is empty: rejected with the alert "Error parsing SBOM reports" and no row, because its empty version is invalid.
  4. Read log/application_json.log for the pipeline of the SBOM that records no file for its packages.
    • Observed: the line "Skipped third-party SBOM component" with skipped_component_count_by_reason showing 1 for "unsupported component type" (pkg:maven/org.apache.commons/commons-text@1.8, component type framework), once for each time the pipeline reads the SBOM.
  5. Add a GitLab DS analyzer SBOM, for example the SBOM of the Maven core module.
    • Observed: 5 rows at core/pom.xml, package manager maven.

MR acceptance checklist

Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Igor Frenkel

Merge request reports

Loading
Loading