Introducing a new way to review your PRs.

Read the announcement

prowler-cloud / prowler

This repo hosts Prowler OSS (CLI and Local Server). Prowler is the world’s most widely used open-source cloud security platform that automates security and compliance across any cloud environment for Humans and AI Agents.

View on GitHub

13 documents · Updated Nov 16, 2026

docs / cli-scan-engine

CLI scan engine

Overview

The local CLI starts at prowler-cli.py, which delegates directly to prowler.__main__.prowler(). prowler/__main__.py is the end-to-end orchestration point: it parses command-line arguments, loads metadata and compliance definitions, initializes the provider, resolves the scan scope, runs checks or external-tool scans, converts reports into findings, writes outputs, optionally pushes OCSF to Prowler Cloud, prints summaries, and sets the final process exit code.

Argument parsing is centralized in prowler/…/parser.py. ProwlerArgumentParser builds a top-level prowler parser plus provider subparsers, adds common scan/output/logging/configuration arguments, then delegates provider-specific parser setup through init_providers_parser(self). If no provider is supplied, parse() injects aws; if the second token is a flag, it also injects aws before parsing. Provider aliases are normalized through PROVIDER_ALIASES, and provider-level validation is run via validate_provider_arguments, validate_asff_usage, and validate_sarif_usage. Before parsing, prowler/…/redact.py warns when sensitive flags, currently common --shodan from prowler/…/sensitive.py plus provider-declared SENSITIVE_ARGUMENTS, are passed with explicit command-line values.

prowler/__main__.py treats list operations as early exits. --list-services, --list-fixer, --list-categories, --list-resource-groups, --list-compliance, --list-compliance-requirements, --list-checks, and --list-checks-json all load only the metadata needed for that listing and then sys.exit(). For normal scans it loads check metadata with CheckMetadata.get_bulk(provider) from prowler/…/models.py, optionally augments it with folder-provided custom check metadata from load_custom_checks_metadata, loads legacy compliance frameworks with Compliance.get_bulk(provider), loads universal compliance frameworks with get_bulk_compliance_frameworks_universal(provider), and merges legacy compliance references into check metadata through update_checks_metadata_with_compliance in prowler/…/compliance.py. Custom metadata overrides from --custom-checks-metadata-file are parsed by prowler/…/custom_checks_metadata.py and update only allowed fields under Checks.

The check scope is calculated by load_checks_to_execute() in prowler/…/checks_loader.py. It selects checks from bulk metadata by, in priority order, explicit --check, --severity optionally intersected with --service, --checks-file, --service, --compliance, --category, --resource-group, or all checks. It expands check aliases after selection and excludes threat-detection category checks by default unless the user requested that category, selected a specific check, or is listing checks. Invalid checks, services, categories, and resource groups are fail-fast sys.exit(1) paths in the loader; resource-group matching is case-insensitive. --excluded-check, --excluded-checks-file, and --excluded-service are applied later in prowler/__main__.py through exclude_checks_to_run, parse_checks_from_file, and exclude_services_to_run from prowler/…/check.py. Provider resource filters are also applied late: after Provider.init_global_provider(args), global_provider.get_checks_to_execute_by_audit_resources() is intersected when --resource-arn or --resource-tag is present.

Provider initialization happens in prowler/__main__.py via Provider.init_global_provider(args) after check-list resolution, then Provider.get_global_provider() supplies credentials, identity, mutelist, audit config, and provider-specific output options. Output options are still routed by a large provider switch in prowler/__main__.py, falling back to global_provider.get_output_options() or default_output_options() for external providers. The --quick-inventory path runs run_provider_quick_inventory(global_provider, args) and exits before checks execute.

Standard check execution is handled by execute_checks() in prowler/…/check.py. It initializes global_provider.audit_metadata, raises the process file descriptor soft limit to 4096 on non-Windows when possible, prints scan configuration unless --only-logs, wraps execution in an alive_progress bar, imports each check module through _resolve_check_module(), instantiates the check class, calls execute(), reports verbose output, applies mutelist/status filtering in execute(), and updates audit metadata with completed services/checks. _resolve_check_module() gives built-in checks precedence over entry-point plugins and only falls back to importlib.metadata.entry_points(group=f"prowler.checks.{provider_type}") when the built-in check does not exist.

The Check and finding-report contract lives in prowler/…/models.py. Each check class derives from Check, whose constructor loads the sibling .metadata.json, validates it as CheckMetadata, and enforces that CheckID, class name, and file name match. Provider-specific Check_Report_* dataclasses normalize resource IDs, names, regions, tenants, or locations for output conversion; the base Check_Report redacts sensitive fields from resource metadata. CheckMetadata.get_bulk() discovers checks with recover_checks_from_provider() in prowler/…/utils.py, loads each metadata file, and keeps the first metadata on duplicate CheckID so built-ins win over plugin collisions.

Tool-wrapper providers take a different route. prowler/…/external_tool_providers.py declares built-in wrappers iac, llm, and image, and prowler/…/tool_wrapper.py extends that classification to external provider entry points that set is_external_tool_provider = True. The loader, discovery utilities, metadata validators, and CLI all consult this single classification. In prowler/__main__.py, tool-wrapper providers bypass standard check/service loading and call provider methods directly (run_scan() for llm, run() for iac, image, and external wrappers), then apply status filtering and output reporting.

The reusable SDK-style scan API is Scan in prowler/…/scan.py. Unlike the CLI orchestration, Scan accepts a provider object and scope lists, validates checks/services/compliance/categories/severities/status, sorts selected checks by severity then name, tracks service/check completion, and yields (progress, findings) as each check completes. It uses the same load_checks_to_execute(), _resolve_check_module(), execute(), Finding.generate_output(), and audit metadata update functions as the CLI path. It has special streaming branches for IacProvider and ImageProvider, converting their Trivy-style reports into Finding objects and yielding progress per scan or per image. Invalid scan inputs raise typed exceptions from prowler/…/exceptions.py rather than exiting.

Runtime configuration defaults and config-file loading are in prowler/…/config.py. CLI defaults include default_output_directory, default_config_file_path, default_fixer_config_file_path, output suffixes, allowed output formats, Prowler Cloud API environment variables, and mutable timestamps used for output filenames. load_and_validate_config_file(provider, path) accepts namespaced config files ({provider: {...}}) for all providers and the legacy flat format only for AWS, then validates through the provider schema in prowler/…/registry.py. The runtime validator in prowler/…/validator.py is intentionally lenient: invalid fields are logged and dropped so checks fall back to defaults. The stricter app/UI-facing schema bridge in prowler/…/scan_config_schema.py validates provider sections, normalizes JSON-serializable config, preserves unknown provider sections when serializable, and additionally validates excluded_checks and excluded_services against the current catalog.

After checks run, prowler/__main__.py converts each check report to an output Finding, extracts statistics, optionally sends Slack summaries, writes requested output formats (csv, json-asff, json-ocsf, html, sarif), optionally creates a temporary OCSF file for --push-to-cloud, and generates compliance outputs. Universal compliance frameworks are processed first so framework names handled by process_universal_compliance_frameworks() are removed before legacy provider-specific compliance output switches run. AWS-only post-processing includes optional S3 upload and Security Hub submission/archive. The run ends by displaying summary and default-execution compliance tables, removing copied custom check modules, and exiting with code 3 when there are unmuted FAIL findings unless --ignore-exit-code-3 is set.

prowler/…/scan_filters.py is the small shared resource-filter helper: is_resource_filtered(resource, audit_resources) returns true when the resource string is exactly present in the provider's audit-resource list. Provider code uses this simple predicate for ARN/name based filtering outside the central loader.

Coupling

  • If a provider is added or renamed, update both provider parser registration outside this doc's scope and the CLI constants in prowler/…/parser.py, plus config schema registration in prowler/…/registry.py when the provider supports --config-file; otherwise prowler/__main__.py can parse or initialize a provider whose config is never validated, or the parser can reject a valid provider.
  • If a provider should bypass normal checks, update EXTERNAL_TOOL_PROVIDERS in prowler/…/external_tool_providers.py or set is_external_tool_provider = True on the entry-point provider class; otherwise load_checks_to_execute() and recover_checks_from_provider() will try to discover .metadata.json checks and the CLI will take the standard check execution path.
  • If check naming rules change, update Check/CheckMetadata validation in prowler/…/models.py, service derivation in prowler/…/scan.py, service exclusion in prowler/…/check.py, and recover_checks_from_provider() in prowler/…/utils.py together. Multiple paths assume the service name is the first underscore-delimited segment of CheckID, with AWS lambda normalized to awslambda in selected helpers.
  • If a new check-selection mode is added to prowler/…/parser.py, also update default_execution and load_checks_to_execute() usage in prowler/__main__.py; default execution controls automatic compliance output selection and whether summary compliance tables are printed.
  • If threat-detection checks should run under different defaults, change load_checks_to_execute() and its tests in tests/…/check_loader_test.py; the current behavior deliberately excludes Categories=["threat-detection"] except for explicit category/check selection and check listing.
  • If custom check folder behavior changes, keep load_custom_checks_metadata(), parse_checks_from_folder(), and remove_custom_checks_module() in prowler/…/check.py aligned. The CLI reads custom metadata before provider initialization, later copies custom check code into prowler/providers/{provider}/services/{service}/{check}/, and removes those copied modules at the end of the run.
  • If compliance framework loading changes, verify both legacy Compliance.get_bulk()/update_checks_metadata_with_compliance() and universal get_bulk_compliance_frameworks_universal() flows. prowler/__main__.py lists frameworks from the union, selects compliance checks through load_checks_to_execute(), and later subtracts universal-processed frameworks before legacy provider-specific output generation.
  • If config exclusions (excluded_checks, excluded_services) are changed in provider schema models, update both lenient runtime validation in prowler/…/validator.py and strict catalog validation in prowler/…/scan_config_schema.py; the SDK Scan class separately enforces duplicates/unknown exclusions and raises ScanInvalid* exceptions.

Risks

  • prowler/__main__.py contains the provider output-options and compliance-output routing as large explicit switches. If a provider is added without updating these branches or implementing the dynamic fallback methods, scans may execute but produce generic or missing provider-specific output/compliance artifacts.
  • parse_checks_from_folder() and remove_custom_checks_module() in prowler/…/check.py copy and delete directories inside prowler/providers/{provider}/services/.... If a custom check name collides with a built-in check directory, the copy step removes the existing directory before copying, so failures before cleanup can leave the local source tree altered for the remainder of the process.
  • execute() in prowler/…/check.py catches exceptions raised by a check's execute() method, logs them, and returns an empty finding list. A broken check therefore does not fail the whole CLI run; reviewers changing check execution should verify that logged errors remain visible enough for CI and users.
  • Scan.scan() filters findings by mutating check_findings while iterating it in prowler/…/scan.py. If multiple findings are filtered by status, adjacent non-matching findings can be skipped by list mutation semantics, so changes to SDK scan status filtering should prefer a new filtered list.