Skip to content

API Reference parrot_tools.security.trivy.executor

github-actions[bot] edited this page Dec 2, 2026 · 4 revisions

parrot_tools.security.trivy.executor

View source

Trivy executor for running security scans.

Extends BaseExecutor to provide Trivy-specific CLI argument building and helper methods for common scan types.

Alias BaseExecutor

Re-exported from parrot_tools.security.base_executor.BaseExecutor.

Class ImageNotFoundError

Raised when a trivy image target is not present on the local Docker daemon.

Surfaced by the pre-flight check in TrivyExecutor.scan_image so the caller gets a clear, actionable error before Trivy spends ~10 seconds downloading the vulnerability DB only to fail on image resolution.

Alias TrivyConfig

Re-exported from parrot_tools.security.trivy.config.TrivyConfig.

Class TrivyExecutor

Executes Trivy security scans via Docker or direct CLI.

Trivy CLI pattern: trivy <scan_type> [options] <target>

Scan types:

  • image: Container image vulnerability scanning
  • fs: Filesystem vulnerability and secret scanning
  • repo: Git repository scanning
  • config: IaC misconfiguration detection
  • k8s: Kubernetes cluster scanning
  • sbom: Software Bill of Materials generation
Parameter Type Default Description
config Optional[TrivyConfig] None Trivy configuration. Uses defaults if not provided.

Attributes:

Attribute Type Description
config TrivyConfig

Method TrivyExecutor.scan_image

Scan a container image for vulnerabilities.

scan_image(image: str, severity: Optional[list[str]] = None, ignore_unfixed: Optional[bool] = None, scanners: Optional[list[str]] = None) -> tuple[str, str, int]

Parameter Type Default Description
image str Image name with optional tag (e.g., "nginx:latest").
severity Optional[list[str]] None Override severity filter.
ignore_unfixed Optional[bool] None Override ignore_unfixed setting.
scanners Optional[list[str]] None Override scanner types.

Returns: tuple[str, str, int] — Tuple of (stdout, stderr, exit_code).

Raises:

  • ImageNotFoundError — If preflight_image_check is enabled and the image is not present on the local Docker daemon.

Method TrivyExecutor.scan_filesystem

Scan a filesystem directory for vulnerabilities and secrets.

scan_filesystem(path: str, severity: Optional[list[str]] = None, scanners: Optional[list[str]] = None) -> tuple[str, str, int]

Parameter Type Default Description
path str Path to directory or file to scan.
severity Optional[list[str]] None Override severity filter.
scanners Optional[list[str]] None Override scanner types.

Returns: tuple[str, str, int] — Tuple of (stdout, stderr, exit_code).

Method TrivyExecutor.scan_repository

Scan a Git repository for vulnerabilities.

scan_repository(repo_url: str, branch: Optional[str] = None, severity: Optional[list[str]] = None) -> tuple[str, str, int]

Parameter Type Default Description
repo_url str Git repository URL.
branch Optional[str] None Branch to scan (default: default branch).
severity Optional[list[str]] None Override severity filter.

Returns: tuple[str, str, int] — Tuple of (stdout, stderr, exit_code).

Method TrivyExecutor.scan_config

Scan IaC configuration files for misconfigurations.

Supports Terraform, CloudFormation, Kubernetes manifests, Dockerfile, and more.

scan_config(path: str, compliance: Optional[str] = None, policy_dir: Optional[str] = None) -> tuple[str, str, int]

Parameter Type Default Description
path str Path to IaC configuration directory or file.
compliance Optional[str] None Compliance specification to check against.
policy_dir Optional[str] None Custom policy directory.

Returns: tuple[str, str, int] — Tuple of (stdout, stderr, exit_code).

Method TrivyExecutor.scan_k8s

Scan a Kubernetes cluster for vulnerabilities and misconfigurations.

scan_k8s(context: Optional[str] = None, namespace: Optional[str] = None, compliance: Optional[str] = None, components: Optional[list[str]] = None) -> tuple[str, str, int]

Parameter Type Default Description
context Optional[str] None Kubernetes context to use.
namespace Optional[str] None Namespace to scan (None = all namespaces).
compliance Optional[str] None Compliance specification (e.g., "k8s-cis-1.23").
components Optional[list[str]] None K8s components to scan (workload, infra, rbac).

Returns: tuple[str, str, int] — Tuple of (stdout, stderr, exit_code).

Method TrivyExecutor.generate_sbom

Generate a Software Bill of Materials (SBOM) for a target.

generate_sbom(target: str, scan_type: str = 'image', sbom_format: str = 'cyclonedx', output_file: Optional[str] = None) -> tuple[str, str, int]

Parameter Type Default Description
target str Target to generate SBOM for (image name or path).
scan_type str 'image' Type of target (image, fs, repo).
sbom_format str 'cyclonedx' SBOM format (cyclonedx, spdx, spdx-json).
output_file Optional[str] None Output file path (defaults to stdout).

Returns: tuple[str, str, int] — Tuple of (stdout, stderr, exit_code).

Method TrivyExecutor.list_scanners

List available scanner types.

list_scanners() -> tuple[str, str, int]

Returns: tuple[str, str, int] — Tuple of (stdout, stderr, exit_code).

Architecture

Clients

Bots & Agents

Memory

Knowledge

Tools & Toolkits

Flows

Experts

Skills

Stores & Loaders

MCP & A2A

Server & APIs

Integrations

Outputs & A2UI

Prompts

Security

Operations

Migration

SDD Tooling

LLM Wiki

Deployment

Decisions

API Reference

Clone this wiki locally