Loading
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::Cdxgenis a new format class, added to the list afterSyft. It reads only the files cdxgen records, and the previous MRs of the stack handle everything else.Normalizer::Cdxgen#source_filesreturns 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-textis typedframeworkby 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.xmlandfoo/pom.xmlis also a row of GitLab's at that path.
- GitLab's own SBOM of the same project is unchanged:
core/pom.xmlhas 5 rows andfoo/pom.xmlhas 9 rows.
References
Screenshots or screen recordings
No UI change.
How to set up and validate locally
- In a Rails console on a development instance run
Feature.enable(:third_party_sbom_support). - Create a project, add an SBOM of one of the kinds below and a
.gitlab-ci.ymljob that uploads it asartifacts:reports:cyclonedx, and run the pipeline. - Open the Dependency List and read the location of each row, or the
dependenciesGraphQL 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.xmlcore and commons-lang3,bar/pom.xmlcommons-lang3,pom.xmlcore and commons-lang3.
- Expected: 5 rows,
- 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:workspaceSrcFileare not read.
- Expected: 4 rows at
- A cdxgen 13.0.1 SBOM of a multi-module Maven project.
- Add a GitLab DS analyzer SBOM, for example the SBOM of the Maven
coremodule.- Expected: 5 rows at
core/pom.xml, package manager maven.
- Expected: 5 rows at
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