The Harbor Scanner Adapter for Trivy is a service that translates the Harbor scanning
API into Trivy commands and allows Harbor to use Trivy for providing vulnerability reports on images stored in Harbor
registry as part of its vulnerability scan feature.
Harbor Scanner Adapter for Trivy is the default static vulnerability scanner in Harbor >= 2.2.
For compliance with core components Harbor builds the adapter service binaries into Docker images based on Photos OS
(goharbor/trivy-adapter-photon), whereas in this repository we build Docker images based on Alpine
(aquasec/harbor-scanner-trivy). There is no difference in functionality though.
In Harbor >= 2.0 Trivy can be configured as the default vulnerability scanner, therefore you can install it with the
official Harbor Helm chart, where HARBOR_CHART_VERSION >= 1.4:
Enable VEX, possible values are oci and repo [EXPERIMENTAL]
SCANNER_TRIVY_SKIP_VEX_REPO_UPDATE
false
Skip updating the VEX repository [EXPERIMENTAL]
SCANNER_STORE_REDIS_NAMESPACE
harbor.scanner.trivy:store
The namespace for keys in the Redis store
SCANNER_STORE_REDIS_SCAN_JOB_TTL
1h
The time to live for persisting scan jobs and associated scan reports
SCANNER_JOB_QUEUE_REDIS_NAMESPACE
harbor.scanner.trivy:job-queue
The namespace for keys in the scan jobs queue backed by Redis
SCANNER_JOB_QUEUE_WORKER_CONCURRENCY
1
The number of workers to spin-up for the scan jobs queue
SCANNER_REDIS_URL
redis://harbor-harbor-redis:6379
The Redis server URI. The URI supports schemas to connect to a standalone Redis server, i.e. redis://:password@standalone_host:port/db-number and Redis Sentinel deployment, i.e. redis+sentinel://:password@sentinel_host1:port1,sentinel_host2:port2/monitor-name/db-number.
SCANNER_REDIS_POOL_MAX_ACTIVE
5
The max number of connections allocated by the Redis connection pool
SCANNER_REDIS_POOL_MAX_IDLE
5
The max number of idle connections in the Redis connection pool
SCANNER_REDIS_POOL_IDLE_TIMEOUT
5m
The duration after which idle connections to the Redis server are closed. If the value is zero, then idle connections are not closed.
SCANNER_REDIS_POOL_CONNECTION_TIMEOUT
1s
The timeout for connecting to the Redis server
SCANNER_REDIS_POOL_READ_TIMEOUT
1s
The timeout for reading a single Redis command reply
Releases - how to release a new version of harbor-scanner-trivy.
Troubleshooting
Error: database error: –skip-db-update cannot be specified on the first run
If you set the value of the SCANNER_TRIVY_SKIP_UPDATE to true, make sure that you download the Trivy DB
and mount it in the /home/scanner/.cache/trivy/db/trivy.db path.
Most likely it’s a Docker DNS server or network firewall configuration issue. Trivy requires internet connection to
periodically download vulnerability database from GitHub to show up-to-date risks.
Try adding a DNS server to docker-compose.yml created by Harbor installer.
version: 2
services:
trivy-adapter:
# NOTE Adjust IPs to your environment.
dns:
- 8.8.8.8
- 192.168.1.1
Alternatively, configure Docker daemon to use the same DNS server as host operating system. See DNS services
section in the Docker container networking documentation for more details.
Trivy DB downloads from GitHub are subject to rate limiting. Make sure that the Trivy DB is mounted
and cached in the /home/scanner/.cache/trivy/db/trivy.db path. If, for any reason, it’s not enough you can set the
value of the SCANNER_TRIVY_GITHUB_TOKEN environment variable (authenticated requests get a higher rate limit).
Contributing
Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull
requests.
Harbor Scanner Adapter for Trivy is an Aqua Security open source project. Learn about our open source work and portfolio here.
Harbor Scanner Adapter for Trivy
The Harbor Scanner Adapter for Trivy is a service that translates the Harbor scanning API into Trivy commands and allows Harbor to use Trivy for providing vulnerability reports on images stored in Harbor registry as part of its vulnerability scan feature.
Harbor Scanner Adapter for Trivy is the default static vulnerability scanner in Harbor >= 2.2.
For compliance with core components Harbor builds the adapter service binaries into Docker images based on Photos OS (
goharbor/trivy-adapter-photon), whereas in this repository we build Docker images based on Alpine (aquasec/harbor-scanner-trivy). There is no difference in functionality though.TOC
Version Matrix
The following matrix indicates the version of Trivy and Trivy adapter installed in each Harbor release.
Note: The version matrix is not exhaustive. For older versions please refer to https://github.com/aquasecurity/harbor-scanner-trivy
Deployment
In Harbor >= 2.0 Trivy can be configured as the default vulnerability scanner, therefore you can install it with the official Harbor Helm chart, where
HARBOR_CHART_VERSION>= 1.4:The adapter service is automatically registered under the Interrogation Service in the Harbor interface and designated as the default scanner.
Configuration
Configuration of the adapter is done via environment variables at startup.
SCANNER_LOG_LEVELinfotrace,debug,info,warn,warning,error,fatalorpanic. The standard logger logs entries with that level or anything above it.SCANNER_API_SERVER_ADDR:8080SCANNER_API_SERVER_TLS_CERTIFICATESCANNER_API_SERVER_TLS_KEYSCANNER_API_SERVER_CLIENT_CASSCANNER_API_SERVER_READ_TIMEOUT15sSCANNER_API_SERVER_WRITE_TIMEOUT15sSCANNER_API_SERVER_IDLE_TIMEOUT60sSCANNER_API_SERVER_METRICS_ENABLEDtrueSCANNER_TRIVY_CACHE_DIR/home/scanner/.cache/trivySCANNER_TRIVY_REPORTS_DIR/home/scanner/.cache/reportsSCANNER_TRIVY_DEBUG_MODEfalseSCANNER_TRIVY_VULN_TYPEos,libraryosandlibrary.SCANNER_TRIVY_SECURITY_CHECKSvuln,config,secretvuln,configandsecret. Defaults tovuln.SCANNER_TRIVY_SEVERITYUNKNOWN,LOW,MEDIUM,HIGH,CRITICALSCANNER_TRIVY_IGNORE_UNFIXEDfalseSCANNER_TRIVY_IGNORE_POLICYSCANNER_TRIVY_SKIP_UPDATEfalseSCANNER_TRIVY_SKIP_JAVA_DB_UPDATEfalseSCANNER_TRIVY_DB_REPOSITORYmirror.gcr.io/aquasec/trivy-db,ghcr.io/aquasecurity/trivy-dbSCANNER_TRIVY_JAVA_DB_REPOSITORYghcr.io/aquasecurity/trivy-java-dbSCANNER_TRIVY_OFFLINE_SCANfalseSCANNER_TRIVY_GITHUB_TOKENSCANNER_TRIVY_INSECUREfalseSCANNER_TRIVY_TIMEOUT5m0sSCANNER_TRIVY_VEX_SOURCEociandrepo[EXPERIMENTAL]SCANNER_TRIVY_SKIP_VEX_REPO_UPDATEfalseSCANNER_STORE_REDIS_NAMESPACEharbor.scanner.trivy:storeSCANNER_STORE_REDIS_SCAN_JOB_TTL1hSCANNER_JOB_QUEUE_REDIS_NAMESPACEharbor.scanner.trivy:job-queueSCANNER_JOB_QUEUE_WORKER_CONCURRENCY1SCANNER_REDIS_URLredis://harbor-harbor-redis:6379redis://:password@standalone_host:port/db-numberand Redis Sentinel deployment, i.e.redis+sentinel://:password@sentinel_host1:port1,sentinel_host2:port2/monitor-name/db-number.SCANNER_REDIS_POOL_MAX_ACTIVE5SCANNER_REDIS_POOL_MAX_IDLE5SCANNER_REDIS_POOL_IDLE_TIMEOUT5mSCANNER_REDIS_POOL_CONNECTION_TIMEOUT1sSCANNER_REDIS_POOL_READ_TIMEOUT1sSCANNER_REDIS_POOL_WRITE_TIMEOUT1sHTTP_PROXYHTTPS_PROXYNO_PROXYDocumentation
Troubleshooting
Error: database error: –skip-db-update cannot be specified on the first run
If you set the value of the
SCANNER_TRIVY_SKIP_UPDATEtotrue, make sure that you download the Trivy DB and mount it in the/home/scanner/.cache/trivy/db/trivy.dbpath.Error: failed to list releases: Get https://api.github.com/repos/aquasecurity/trivy-db/releases: dial tcp: lookup api.github.com on 127.0.0.11:53: read udp 127.0.0.1:39070->127.0.0.11:53: i/o timeout
Most likely it’s a Docker DNS server or network firewall configuration issue. Trivy requires internet connection to periodically download vulnerability database from GitHub to show up-to-date risks.
Try adding a DNS server to
docker-compose.ymlcreated by Harbor installer.Alternatively, configure Docker daemon to use the same DNS server as host operating system. See DNS services section in the Docker container networking documentation for more details.
Error: failed to list releases: GET https://api.github.com/repos/aquasecurity/trivy-db/releases: 403 API rate limit exceeded
Trivy DB downloads from GitHub are subject to rate limiting. Make sure that the Trivy DB is mounted and cached in the
/home/scanner/.cache/trivy/db/trivy.dbpath. If, for any reason, it’s not enough you can set the value of theSCANNER_TRIVY_GITHUB_TOKENenvironment variable (authenticated requests get a higher rate limit).Contributing
Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests.
Harbor Scanner Adapter for Trivy is an Aqua Security open source project.
Learn about our open source work and portfolio here.