Skip to content

API Reference parrot_tools.security.container_security_toolkit

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

parrot_tools.security.container_security_toolkit

View source

Container Security Toolkit.

Agent-facing toolkit that wraps Trivy for container, filesystem, Kubernetes, and IaC security scanning. All public async methods automatically become agent tools.

Alias AbstractToolkit

Re-exported from parrot_tools.toolkit.AbstractToolkit.

Alias ComparisonDelta

Re-exported from parrot_tools.security.models.ComparisonDelta.

Class ContainerSecurityToolkit

Container and infrastructure security toolkit powered by Trivy.

Scans container images, filesystems, git repositories, Kubernetes clusters, and Infrastructure as Code for vulnerabilities, secrets, and misconfigurations.

All public async methods automatically become agent tools.

Parameter Type Default Description
config Optional[TrivyConfig] None Optional TrivyConfig. Uses defaults if not provided.
**kwargs {} Additional arguments passed to AbstractToolkit.

Attributes:

Attribute Type Description
name str
description str

Method ContainerSecurityToolkit.trivy_scan_image

Scan a container image for vulnerabilities, secrets, and misconfigurations.

Executes a comprehensive security scan using Trivy to identify CVEs, exposed secrets, and Dockerfile misconfigurations.

trivy_scan_image(image: str, severity: Optional[list[str]] = None, ignore_unfixed: bool = False, scanners: Optional[list[str]] = None) -> ScanResult

Parameter Type Default Description
image str Container image to scan (e.g., 'nginx:latest', 'myrepo/myapp:v1.2').
severity Optional[list[str]] None Filter by severity levels. Options: CRITICAL, HIGH, MEDIUM, LOW. Default: scan all severities.
ignore_unfixed bool False If True, skip vulnerabilities without available fixes.
scanners Optional[list[str]] None Types of scanning to perform. Options: vuln, misconfig, secret, license. Default: ['vuln', 'secret'].

Returns: ScanResult — ScanResult with CVEs, secrets, and misconfigs found in the image.

Method ContainerSecurityToolkit.trivy_scan_filesystem

Scan a local filesystem directory for vulnerabilities and secrets.

Detects vulnerable dependencies, exposed secrets, and misconfigurations in a local directory.

trivy_scan_filesystem(path: str, severity: Optional[list[str]] = None, scanners: Optional[list[str]] = None) -> ScanResult

Parameter Type Default Description
path str Path to directory or file to scan.
severity Optional[list[str]] None Filter by severity levels. Options: CRITICAL, HIGH, MEDIUM, LOW.
scanners Optional[list[str]] None Types of scanning. Options: vuln, misconfig, secret, license. Default: ['vuln', 'secret', 'misconfig'].

Returns: ScanResult — ScanResult with findings from the filesystem scan.

Method ContainerSecurityToolkit.trivy_scan_repo

Scan a Git repository for vulnerabilities.

Clones and scans a Git repository to detect vulnerable dependencies and exposed secrets.

trivy_scan_repo(repo_url: str, branch: Optional[str] = None, severity: Optional[list[str]] = None) -> ScanResult

Parameter Type Default Description
repo_url str Git repository URL (e.g., 'https://github.com/org/repo.git').
branch Optional[str] None Branch to scan. If None, uses the default branch.
severity Optional[list[str]] None Filter by severity levels. Options: CRITICAL, HIGH, MEDIUM, LOW.

Returns: ScanResult — ScanResult with findings from the repository scan.

Method ContainerSecurityToolkit.trivy_scan_k8s

Scan a Kubernetes cluster for vulnerabilities and misconfigurations.

Scans running workloads, RBAC configurations, and cluster infrastructure for security issues.

trivy_scan_k8s(context: Optional[str] = None, namespace: Optional[str] = None, compliance: Optional[str] = None, components: Optional[list[str]] = None) -> ScanResult

Parameter Type Default Description
context Optional[str] None Kubernetes context to use. If None, uses current context.
namespace Optional[str] None Namespace to scan. If None, scans all namespaces.
compliance Optional[str] None Compliance specification to check (e.g., 'k8s-cis-1.23').
components Optional[list[str]] None K8s components to scan. Options: workload, infra, rbac.

Returns: ScanResult — ScanResult with findings from the Kubernetes cluster scan.

Method ContainerSecurityToolkit.trivy_scan_iac

Scan Infrastructure as Code configurations for misconfigurations.

Detects security issues in Terraform, CloudFormation, Kubernetes manifests, Dockerfiles, and other IaC configurations.

trivy_scan_iac(path: str, compliance: Optional[str] = None, config_type: Optional[str] = None) -> ScanResult

Parameter Type Default Description
path str Path to IaC configuration directory or file.
compliance Optional[str] None Compliance specification (e.g., 'aws-cis-1.4.0').
config_type Optional[str] None Configuration type hint (terraform, cloudformation, kubernetes, dockerfile). Auto-detected if not specified.

Returns: ScanResult — ScanResult with IaC misconfigurations found.

Method ContainerSecurityToolkit.trivy_generate_sbom

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

Creates a machine-readable inventory of all software components, dependencies, and their versions.

trivy_generate_sbom(target: str, format: str = 'cyclonedx', output_path: Optional[str] = None, scan_type: str = 'image') -> str

Parameter Type Default Description
target str Target to generate SBOM for (image name or filesystem path).
format str 'cyclonedx' SBOM format. Options: cyclonedx, spdx, spdx-json. Default: cyclonedx.
output_path Optional[str] None Path to save the SBOM file. If None, returns content.
scan_type str 'image' Type of target. Options: image, fs, repo. Default: image.

Returns: str — Path to the generated SBOM file, or SBOM content if no output_path.

Method ContainerSecurityToolkit.trivy_get_summary

Get summary statistics from the last scan.

Returns aggregated metrics from the most recent scan including finding counts by severity and resource types scanned.

trivy_get_summary() -> dict

Returns: dict — Dictionary with summary statistics:

  • total_findings: Total number of findings
  • critical_count: Critical severity findings
  • high_count: High severity findings
  • medium_count: Medium severity findings
  • low_count: Low severity findings
  • info_count: Informational findings
  • services_scanned: List of scanned resource types
  • scan_timestamp: ISO timestamp of the scan Returns empty dict if no scan has been run.

Method ContainerSecurityToolkit.trivy_get_findings

Get findings from the last scan with optional filters.

Retrieves security findings from the most recent scan, optionally filtered by severity or scanner type (resource_type).

trivy_get_findings(severity: Optional[str] = None, scanner_type: Optional[str] = None, limit: Optional[int] = None) -> list[SecurityFinding]

Parameter Type Default Description
severity Optional[str] None Filter by severity level. Options: CRITICAL, HIGH, MEDIUM, LOW, INFO.
scanner_type Optional[str] None Filter by scanner type (maps to resource_type). Options: vulnerability, secret, Dockerfile, etc.
limit Optional[int] None Maximum number of findings to return.

Returns: list[SecurityFinding] — List of SecurityFinding objects matching the filters. Returns empty list if no scan has been run.

Method ContainerSecurityToolkit.trivy_generate_report

Generate a report from the last scan results.

Creates a formatted report file from the most recent scan findings.

trivy_generate_report(output_path: str, format: str = 'html') -> str

Parameter Type Default Description
output_path str Path where the report file will be saved.
format str 'html' Report format. Options: html, json.

Returns: str — Path to the generated report file.

Raises:

  • ValueError — If no scan has been run yet.

Method ContainerSecurityToolkit.trivy_compare_scans

Compare current scan results against a baseline.

Identifies new findings (regressions), resolved findings (improvements), and unchanged findings between the current scan and a saved baseline.

trivy_compare_scans(baseline_path: str) -> ComparisonDelta

Parameter Type Default Description
baseline_path str Path to the baseline scan result JSON file.

Returns: ComparisonDelta — ComparisonDelta with:

  • new_findings: Findings in current but not in baseline
  • resolved_findings: Findings in baseline but not in current
  • unchanged_findings: Findings present in both
  • severity_trend: Change in severity counts
  • summary: Human-readable summary of changes

Raises:

  • ValueError — If no current scan results or baseline cannot be loaded.

Alias ReportPersistenceMixin

Re-exported from parrot_tools.security.persistence.ReportPersistenceMixin.

Alias ScanResult

Re-exported from parrot_tools.security.models.ScanResult.

Alias SecurityFinding

Re-exported from parrot_tools.security.models.SecurityFinding.

Alias SeverityLevel

Re-exported from parrot_tools.security.models.SeverityLevel.

Alias TrivyConfig

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

Alias TrivyExecutor

Re-exported from parrot_tools.security.trivy.executor.TrivyExecutor.

Alias TrivyParser

Re-exported from parrot_tools.security.trivy.parser.TrivyParser.

Alias pop_persistence_kwargs

Re-exported from parrot_tools.security.persistence.pop_persistence_kwargs.

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