Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Implementation:0xSteph Pentest ai PentestConfig

From Leeroopedia
Knowledge Sources
Domains Configuration, YAML, Settings_Management
Last Updated 2026-10-23 00:00 GMT

Overview

Concrete tool for loading, validating, and serializing pentest-ai configuration from YAML files with environment variable interpolation, provided by the pentest-ai config module.

Description

The PentestConfig dataclass is the top-level configuration object for pentest-ai. It composes sub-configs: LLMConfig, AgentConfig, ScanConfig, DBConfig, ReportConfig, LicenseConfig, and WebhookConfig. The from_file classmethod searches a list of config paths, interpolates ${ENV_VAR} references, and loads YAML. The to_dict method serializes config with optional secret masking. Uses python-dotenv to load .env files.

Usage

Import this class when you need to load or inspect pentest-ai configuration. Used by the CLI, orchestrator, and agent loop to configure runtime behavior.

Code Reference

Source Location

Signature

@dataclass
class PentestConfig:
    llm: LLMConfig = field(default_factory=LLMConfig)
    agent: AgentConfig = field(default_factory=AgentConfig)
    scan: ScanConfig = field(default_factory=ScanConfig)
    db: DBConfig = field(default_factory=DBConfig)
    report: ReportConfig = field(default_factory=ReportConfig)
    license: LicenseConfig = field(default_factory=LicenseConfig)
    webhook: WebhookConfig = field(default_factory=WebhookConfig)
    plugins_dir: str = ...
    evidence_dir: str = ...
    scope: dict[str, Any] = ...

    @classmethod
    def from_file(cls, path: str | None = None) -> "PentestConfig": ...
    def to_dict(self, mask_secrets: bool = False) -> dict[str, Any]: ...

Import

from config.settings import PentestConfig, LLMConfig, AgentConfig, ScanConfig

I/O Contract

Inputs

Name Type Required Description
path None No Config file path. Auto-searches if None.
mask_secrets bool No Mask API keys in to_dict output

Outputs

Name Type Description
PentestConfig dataclass Full configuration with all sub-configs populated
to_dict dict Serialized config with optional secret masking

Usage Examples

Load Configuration

from config.settings import PentestConfig

# Auto-search config paths (config/pentest-ai.yaml, ~/.pentest-ai/config.yaml, pentest-ai.yaml)
config = PentestConfig.from_file()

print(f"LLM: {config.llm.provider}/{config.llm.model}")
print(f"Intensity: {config.scan.default_intensity}")
print(f"Max concurrent tools: {config.agent.max_concurrent_tools}")

Load with Env Interpolation

from config.settings import PentestConfig

# YAML with ${ENV_VAR} interpolation:
# llm:
#   api_key: ${OPENAI_API_KEY}
config = PentestConfig.from_file("config/pentest-ai.yaml")
print(config.to_dict(mask_secrets=True))  # API key masked

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment