Read the source files of a cdxgen SBOM

What does this MR do and why?

This MR reads each internal:SrcFile property (cdxgen 13) and SrcFile property (cdxgen 12) that cdxgen writes on a package and lists the package at each of those files, so each package appears at the manifest or lockfile that declares it, as GitLab lists the packages of its own analyzer.

  • Normalizer::Cdxgen is a new format class, added to the list after Syft. It reads only the files cdxgen records, and the previous MRs of the stack handle everything else.
  • Normalizer::Cdxgen#source_files returns the values of those properties without a leading slash, because the GitLab DS analyzer's paths are relative.
    • A blank value and a repeated file are ignored.
  • A package with none keeps the default location.
  • A package that records files for several formats is listed at the files of the first format, in the order Syft, then cdxgen.

This MR is the fifth of 8 in a stack. The next one is Read the source files of a Trivy filesystem SBOM (!264255) • Unassigned • 19.7.

Example

A component of a cdxgen 13.0.1 SBOM of a Maven project (trimmed): one property for each file that lists the package.

{
  "name": "commons-text",
  "version": "1.8",
  "purl": "pkg:maven/org.apache.commons/commons-text@1.8?type=jar",
  "properties": [
    { "name": "internal:SrcFile", "value": "core/pom.xml" },
    { "name": "internal:SrcFile", "value": "foo/pom.xml" },
    { "name": "internal:SrcFile", "value": "pom.xml" }
  ]
}
  • Before this MR: the SBOM gives 5 rows at 3rd Party Input File Path Unknown.
  • After this MR: 14 rows.
  • commons-text is typed framework by cdxgen. It is read as a library since Read a framework component of a third-party SBO... (!264252 - merged), and this MR gives it its files.
    • core/pom.xml, 4 rows: commons-io 2.4, commons-text 1.8, log4j-api 2.14.1, log4j-core 2.14.1.
    • foo/pom.xml, 5 rows: those four and core 1.0.0.
    • pom.xml, 5 rows: the same five.
      • This is the aggregate manifest, which GitLab does not list.
    • Each of the 9 rows at core/pom.xml and foo/pom.xml is also a row of GitLab's at that path.
  • 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 }).
    • A cdxgen 13.0.1 SBOM of a multi-module Maven project.
      • Expected: 14 rows.
      • core/pom.xml: commons-io, commons-text, log4j-api, log4j-core.
      • foo/pom.xml: those four and core.
      • pom.xml: the same five.
    • A cdxgen 12.7.0 SBOM of a multi-module Maven project, with the property SrcFile.
      • Expected: 5 rows, foo/pom.xml core and commons-lang3, bar/pom.xml commons-lang3, pom.xml core and commons-lang3.
    • A cdxgen 13.0.1 SBOM of a yarn project.
      • Expected: 4 rows at yarn.lock (debug, lodash, minimist, ms).
      • The workspace manifests recorded in internal:workspaceSrcFile are not read.
  4. Add a GitLab DS analyzer SBOM, for example the SBOM of the Maven core module.
    • Expected: 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