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_filesreturns 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.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 Trivy SBOM of a container image.
- Expected: 3 rows.
opt/app/node_modules/accepts/package.jsonhas accepts,opt/jars/commons-collections-3.2.1.jarhas commons-collections, and musl has no path.
- A Trivy SBOM of a container image.
- 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.