Skip to content

API Reference parrot_tools.security.base_executor

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

parrot_tools.security.base_executor

View source

Base executor for running CLI-based security scanners.

Provides a reusable abstraction for running security scanners via Docker or direct process execution. All scanner executors (Prowler, Trivy, Checkov) inherit from this base class.

Class BaseExecutor

Abstract base executor for Docker or CLI process management.

Provides common functionality for running security scanners:

  • Environment variable building for cloud credentials
  • Docker and direct CLI command construction
  • Async subprocess execution with timeout
  • Credential masking for safe logging

Subclasses must implement:

  • _build_cli_args(): Build scanner-specific CLI arguments
  • _default_cli_name(): Return the default CLI binary name
Parameter Type Default Description
config BaseExecutorConfig Executor configuration including credentials and timeouts.

Method BaseExecutor.execute

Run the scanner and return output.

Executes the scanner either via Docker or direct CLI based on configuration. Handles timeout and process cleanup.

execute(args: Optional[list[str]] = None, **kwargs) -> tuple[str, str, int]

Parameter Type Default Description
args Optional[list[str]] None Pre-built CLI arguments. If None, builds from kwargs.
**kwargs {} Arguments passed to _build_cli_args() if args is None.

Returns: tuple[str, str, int] — Tuple of (stdout, stderr, exit_code). On timeout, exit_code is -1 and stderr contains "Timeout" message.

Method BaseExecutor.execute_streaming

Run the scanner with real-time stderr streaming.

Like execute(), but reads stderr line-by-line and invokes progress_callback for each line. Useful for long-running scans where the user needs progress feedback.

execute_streaming(progress_callback: Callable[[str], None] | None = None, args: list[str] | None = None, **kwargs) -> tuple[str, str, int]

Parameter Type Default Description
progress_callback Callable[[str], None] | None None Called with each stderr line as it arrives.
args list[str] | None None Pre-built CLI arguments. If None, builds from kwargs.
**kwargs {} Arguments passed to _build_cli_args() if args is None.

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

Class BaseExecutorConfig

Base configuration shared by all scanner executors.

Supports credential configuration for AWS, GCP, and Azure cloud providers. Credentials can be provided directly or via profile/file references.

AWS credentials default to values from parrot.conf if available.

Fields:

Field Type Default Description
use_docker bool True Run via Docker or direct CLI
docker_image str '' Docker image to use
cli_path Optional[str] None Path to CLI binary for direct execution
timeout int 600 Execution timeout in seconds
results_dir Optional[str] None Directory to store scan results
aws_access_key_id Optional[str] AWS_ACCESS_KEY_ID AWS access key ID (default from parrot.conf)
aws_secret_access_key Optional[str] AWS_SECRET_ACCESS_KEY AWS secret access key (default from parrot.conf)
aws_session_token Optional[str] None AWS session token for temporary credentials
aws_profile Optional[str] None AWS CLI profile name
aws_region str AWS_DEFAULT_REGION or 'us-east-1' Default AWS region (default from parrot.conf)
gcp_credentials_file Optional[str] None Path to GCP service account JSON file
gcp_project_id Optional[str] None GCP project ID
azure_client_id Optional[str] None Azure AD application (client) ID
azure_client_secret Optional[str] None Azure AD client secret
azure_tenant_id Optional[str] None Azure AD tenant ID
azure_subscription_id Optional[str] None Azure subscription ID

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