Skip to content

Trivy Executor

Category: IaC, Containers and Kubernetes Script: trivy.py Integration: CLI Faraday Plugin: TrivyJsonPlugin Website: https://trivy.dev/

Description

Runs Trivy on a directory, container image, Git repository, IaC configuration or Kubernetes cluster and imports the vulnerabilities, secrets and misconfigurations it finds into Faraday.

Prerequisites

  • trivy installed and available in the agent's PATH (checked with trivy --version)
  • Network access for Trivy to download its vulnerability database and, for images, to pull the image
  • Read access to the target (local path, image, repository or cluster)

Configuration

Environment Variables (Setup)

This executor does not require setup environment variables.

Execution Arguments

Parameter Type Mandatory Description
TRIVY_TARGET string Yes What to scan: a directory (fs), image reference such as nginx:latest (image), repository URL (repo), IaC directory (config) or cluster name (k8s)
TRIVY_SCAN_TYPE string No Trivy scan mode: fs, image, repo, config or k8s (default: fs)
TRIVY_SEVERITY list No Severities to report (e.g., HIGH, CRITICAL). Default: all.
TRIVY_SKIP_DIRS list No Directories to skip (e.g., vendor, node_modules, .git)
TRIVY_SCANNERS string No Comma-separated Trivy scanners to run: vuln, secret, misconfig (default: vuln,secret,misconfig)
TRIVY_IGNORE_UNFIXED boolean No Set to true to hide vulnerabilities that have no upstream fix

YAML Configuration Example

executors:
  trivy:
    repo_executor: trivy.py
    max_size: 65536
    varenvs: {}
    params:
      TRIVY_TARGET:
        mandatory: true
        type: string
        base: string
      TRIVY_SCAN_TYPE:
        mandatory: false
        type: string
        base: string
      TRIVY_SEVERITY:
        mandatory: false
        type: list
        base: list
      TRIVY_SKIP_DIRS:
        mandatory: false
        type: list
        base: list
      TRIVY_SCANNERS:
        mandatory: false
        type: string
        base: string
      TRIVY_IGNORE_UNFIXED:
        mandatory: false
        type: boolean
        base: boolean

How It Works

  1. Builds and runs trivy <scan type> --format json --quiet against TRIVY_TARGET, with the requested scanners, severities, skipped directories and unfixed-vulnerability setting
  2. Parses the JSON output with TrivyJsonPlugin
  3. Sends the resulting hosts and vulnerabilities to Faraday

Notes

  • TRIVY_SCAN_TYPE must be one of fs, image, repo, config or k8s. The run fails for any other value or when TRIVY_TARGET is empty.
  • TRIVY_SCANNERS is only used for the fs, image and repo scan types.
  • The run fails when Trivy produces no output.
  • Supports the shared agent parameters (AGENT_CONFIG_* tags and severity filters).