Skip to content

Grype Executor

Category: IaC, Containers and Kubernetes Script: grype.py Integration: CLI Faraday Plugin: GrypePlugin Website: anchore/grype

Description

Runs the Anchore Grype vulnerability scanner on a container image, directory or SBOM and imports the vulnerabilities found into Faraday.

Prerequisites

  • grype installed and available in the agent's PATH (checked with grype version)
  • Network access to pull the image and the Grype vulnerability database (for image targets)
  • Credentials configured for Grype/Docker if the image is in a private registry

Configuration

Environment Variables (Setup)

This executor does not require setup environment variables.

Execution Arguments

Parameter Type Mandatory Description
GRYPE_TARGET string Yes What to scan: an image name (e.g., alpine:3.10), a directory or an SBOM path
GRYPE_FAIL_ON string No Make Grype report failure when it finds vulnerabilities at or above this severity: negligible, low, medium, high or critical
GRYPE_ONLY_FIXED boolean No Set to true to hide vulnerabilities that have no fix available (default: false)
GRYPE_SCOPE string No Layers to scan: squashed (default, the merged image) or all-layers (every layer)

YAML Configuration Example

executors:
  grype:
    repo_executor: grype.py
    max_size: 65536
    varenvs: {}
    params:
      GRYPE_TARGET:
        mandatory: true
        type: string
        base: string
      GRYPE_FAIL_ON:
        mandatory: false
        type: string
        base: string
      GRYPE_ONLY_FIXED:
        mandatory: false
        type: boolean
        base: boolean
      GRYPE_SCOPE:
        mandatory: false
        type: string
        base: string

How It Works

  1. Runs grype <target> -o json -q, adding --fail-on, --only-fixed and --scope when configured
  2. Parses the JSON output with GrypePlugin and sends the results to Faraday

Notes

  • GRYPE_TARGET accepts anything Grype can scan: an image name (e.g., alpine:3.10), a directory (e.g., dir:/app) or an SBOM file (e.g., sbom:./sbom.json).
  • GRYPE_FAIL_ON makes Grype exit with an error when it finds a vulnerability at or above the given severity. The findings are still imported if Grype prints its results.
  • The executor fails if Grype prints no output.
  • Supports the shared agent parameters (AGENT_CONFIG_* tags and severity filters).