Read the location Trivy records on a package

What does this MR do and why?

This MR reads aquasecurity:trivy:FilePath, the location Trivy records on a package it found as an installed file, such as a jar or a package.json under node_modules, and lists the package at that location, so the package appears where Trivy found it. Trivy usually records it in a scan of a container image, where no manifest component names the package.

  • Normalizer::Trivy#source_files returns the value without its leading slash, with a blank value ignored and a repeated one listed once.
  • A package with no such property is listed at the manifests that reach it, and otherwise at the default location.
  • An operating system package has no source and no path, as on master.

This MR is the seventh of 8 in a stack. The next one is Show the package manager of the packages of a t... (!264257) • Unassigned • 19.7.

Example

A component of a Trivy SBOM of a container image (trimmed, vulnerabilities removed): the file is written on the package.

{
  "type": "library",
  "name": "commons-collections",
  "version": "3.2.1",
  "purl": "pkg:maven/commons-collections/commons-collections@3.2.1",
  "properties": [
    { "name": "aquasecurity:trivy:FilePath", "value": "opt/jars/commons-collections-3.2.1.jar" }
  ]
}
  • Before this MR: 3 rows: accepts 1.3.8 and commons-collections 3.2.1 at 3rd Party Input File Path Unknown, and musl 1.2.5-r3 with no path.
  • After this MR:
    • opt/app/node_modules/accepts/package.json, 1 row: accepts 1.3.8.
    • opt/jars/commons-collections-3.2.1.jar, 1 row: commons-collections 3.2.1.
    • No path, 1 row: musl 1.2.5-r3, an operating system package, as on master.
  • GitLab's own SBOM result 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 Trivy SBOM of a container image.
      • Expected: 3 rows.
      • opt/app/node_modules/accepts/package.json has accepts, opt/jars/commons-collections-3.2.1.jar has commons-collections, and musl has no path.
  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