Trivy#

The Trivy module ingests vulnerability, package, and fix data from Trivy JSON container image and source filesystem scan reports. Findings and packages attach to canonical ontology Image or FilesystemSnapshot nodes.

Cartography currently supports matching Trivy reports to images ingested from AWS ECR, Google Artifact Registry, and GitLab Container Registry. Load the registry’s Cartography module before Trivy so the corresponding canonical image nodes exist.

Git repository scans match FilesystemSnapshot nodes by the repository URL and exact commit recorded in Trivy metadata. The corresponding provider module must create the snapshot before Trivy ingestion runs.

Finding Identifiers#

Trivy findings can carry CVE, GitHub advisory, Debian advisory, RustSec, and other identifiers. Cartography preserves every reported identifier in vulnerability_ids, with the primary VulnerabilityID first, and extracts dedicated cve_id and ghsa_id values when present.

Every finding uses the Risk label. The CVE label is applied only when a CVE identifier is present.

Severity Per Scan Target#

A TrivyImageFinding node is shared by every image and filesystem snapshot that carries the vulnerability, and Trivy can rate the same vulnerability differently in each of them: a Debian package and an Alpine package with the same CVE often carry different severities. The node’s severity, severity_source, status and data_source_id come from the last package row ingested for the finding, across all scans, and the ontology fields _ont_base_severity and _ont_vuln_status follow those node values. For per-target questions, read the same four properties on the AFFECTS relationship from the finding to the Image or FilesystemSnapshot. They hold the raw Trivy values reported for that target.

When several packages in one target carry the same finding, the target takes the rating of one package, chosen by, in order:

  1. the highest severity;

  2. a severity from a named distribution or ecosystem source over an nvd or unnamed one;

  3. no fix available (affected, will_not_fix, fix_deferred, …) over a fix available (fixed, where the installed version is still vulnerable), and fixed over not_affected;

  4. an operating system package over a language package;

  5. report order.

Package Locations#

TrivyPackage nodes are shared by every scan target that contains the same package version, so the files that contain a package are recorded per target, in locations on the DEPLOYED relationship from the package to the Image or FilesystemSnapshot. A location is the lockfile or binary that Trivy read the package from, such as usr/local/bin/app for a Go module compiled into that binary, or the package’s own manifest in an ecosystem that Trivy groups into one result, such as app/node_modules/lodash/package.json. Operating system packages have no location, and neither do grouped packages that Trivy reports without their own file, such as the packages vendored inside pip. To find the locations of an ontology PackageVersion, follow DETECTED_AS to its TrivyPackage nodes.

See configuration for report requirements and source options, queries for query examples, and the generated schema for fields and relationships.