Skip to main content

Trivy component

This component executes Trivy vulnerability and misconfiguration scans against container images or filesystem paths and produces machine-readable reports.

Every container image scan also applies the bundled CRITICAL entitlement policy. Images containing files below /etc/pki/entitlement are rejected so Red Hat subscription certificates and keys cannot be distributed in image layers. This policy remains active when the scanners input omits secret. Set the string input secret-config to other Trivy secret configuration contents to apply a project-specific policy instead.

By default, vulnerabilities without an available fix are excluded. Set the ignore-unfixed input to false to include them.

Set CI_TRIVIY_SERVER_URL to a Trivy server URL, including the http:// or https:// scheme, to run vulnerability and license scanning in client/server mode. The component passes the URL to every image or filesystem scan with Trivy's --server option.

Scans do not run for the renovate/gitlab-pipelines branch, including merge request pipelines for that branch. This branch is generated by the gitlab-pipelines package rule in the shared Renovate configuration. The rules input continues to control all other pipeline contexts.

Variables​

NamerequiredHints
TRIVY_TIMEOUTnoGlobal variable to set a custom scan timeout for long running scans
CI_TRIVIY_SERVER_URLnoTrivy server URL used for client/server scans

Usage​

Scan the filesystem​

  • Create a new pipeline file
include:
- component: $CI_SERVER_FQDN/xrow-public/ci-tools/common@stable
- component: $CI_SERVER_FQDN/xrow-public/ci-tools/tivy@stable
inputs:
name: project
path: .

Scan a container image​

  • Create a new pipeline file
include:
- component: $CI_SERVER_FQDN/xrow-public/ci-tools/common@stable
- component: $CI_SERVER_FQDN/xrow-public/ci-tools/tivy@stable
inputs:
name: image
image: registry.gitlab.com/xrow-public/ci-tools/test-insecure-java-app:latest
ignore-unfixed: false

Inputs​

NameDescriptionDefaultType
------------
dependenciesThe dependencies that this job depends on.[]array
ignore-unfixedExclude vulnerabilities that do not have a fix available.trueboolean
imageUrl to the image.string
nameName for the pipeline jobs and the container.$CI_PROJECT_NAMEstring
needsThe jobs that this job depends on.[]array
package-typesPackage types to scan["os","library"]array
pathPath to the sources..string
rulesThe jobs that this job depends on.[{"if":"$CI_PIPELINE_SOURCE == \"schedule\"","when":"never"},{"if":"$CI_PIPELINE_SOURCE == \"merge_request_event\"","when":"on_success"},{"when":"on_success"}]array
scannersScanners to use. none, vuln, license, secret, misconfig["vuln","secret","license","misconfig"]array
scanning-allow-failureShould the pipeline fail if scanning the built container image fails?trueboolean
scanning-severityWhat level of severity should cause scanning of the built container to fail?CRITICALstring
scanning-timeoutHow long should the scanning process be allowed to run before timing out? Use format e.g. 5m0sstring
secret-configTrivy secret scanner configuration used for image scans.rules: - id: redhat-entitlement-material category: subscription title: Red Hat entitlement material must not be shipped in container images severity: CRITICAL path: '(^|/)etc/pki/entitlement/.+' regex: '(?s).+' string
stageThe pipeline stage that the jobs belongs to.buildstring
tagsThe runners that this job depends on.[]array