Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

pyrit.setup

Module containing initialization PyRIT.

Functions

initialize_from_config_async

initialize_from_config_async(config_path: str | pathlib.Path | None = None) → ConfigurationLoader

Initialize PyRIT from a configuration file.

This is a convenience function that loads a ConfigurationLoader from a YAML file and initializes PyRIT.

ParameterTypeDescription
config_path`strpathlib.Path

Returns:

Raises:

initialize_pyrit_async

initialize_pyrit_async(memory_db_type: MemoryDatabaseType | str, initialization_scripts: Sequence[str | pathlib.Path] | None = None, initializers: Sequence[PyRITInitializer] | None = None, load_defaults: bool = True, env_files: Sequence[pathlib.Path] | None = None, env_akv_ref: Sequence[str] | None = None, silent: bool = False, memory_instance_kwargs: Any = {}) → None

Initialize PyRIT with the provided memory instance and loads environment files.

ParameterTypeDescription
memory_db_typeMemoryDatabaseTypeThe MemoryDatabaseType string literal which indicates the memory instance to use for central memory. Options include “InMemory”, “SQLite”, and “AzureSQL”.
initialization_scripts`Sequence[strpathlib.Path]
initializers`Sequence[PyRITInitializer]None`
load_defaultsboolIf True (default) AND the caller supplies neither initializers nor initialization_scripts, a default initializer set is run so a bare initialize_pyrit_async(...) yields a usable environment: the core attack-technique catalog (TechniqueInitializer, populating the AttackTechniqueRegistry) plus the available default targets (TargetInitializer, registering whatever endpoints are configured via env vars). Supplying any initializer or script means the caller owns setup, so the defaults are skipped; set this to False to also skip them on a bare call (e.g. to start from an empty state). Only the core techniques and default targets are loaded — extra / per-source technique groups and scorer target variants remain opt-in. Defaults to True.
env_files`Sequence[pathlib.Path]None`
env_akv_ref`Sequence[str]None`
silentboolIf True, suppresses print statements about environment file loading and schema migration. Defaults to False. Defaults to False.
**memory_instance_kwargs`AnyNone`

Raises:

ConfigurationLoader

Bases: YamlLoadable

Loader for PyRIT configuration from YAML files.

This class loads configuration from a YAML file and provides methods to initialize PyRIT with the loaded configuration.

Methods:

from_dict

from_dict(data: dict[str, Any]) → ConfigurationLoader

Create a ConfigurationLoader from a dictionary.

ParameterTypeDescription
datadict[str, Any]Dictionary containing configuration values.

Returns:

Raises:

get_default_config_path

get_default_config_path() → pathlib.Path

Get the default configuration file path.

Returns:

initialize_pyrit_async

initialize_pyrit_async() → None

Initialize PyRIT with the loaded configuration.

This method resolves all initializer names to instances and calls the core initialize_pyrit_async function.

Raises:

load_with_overrides

load_with_overrides(config_file: pathlib.Path | None = None, memory_db_type: str | None = None, initializers: Sequence[str | dict[str, Any]] | None = None, initialization_scripts: Sequence[str] | None = None, env_files: Sequence[str] | None = None, env_akv_ref: Sequence[str] | None = None) → ConfigurationLoader

Load configuration with optional overrides.

This factory method implements a 3-layer configuration precedence:

  1. Default config file (~/.pyrit/.pyrit_conf) if it exists

  2. Explicit config_file argument if provided

  3. Individual override arguments (non-None values take precedence)

This is a staticmethod (not classmethod) because it’s a pure factory function that doesn’t need access to class state and can be reused by multiple interfaces (CLI, shell, programmatic API).

ParameterTypeDescription
config_file`pathlib.PathNone`
memory_db_type`strNone`
initializers`Sequence[strdict[str, Any]]
initialization_scripts`Sequence[str]None`
env_files`Sequence[str]None`
env_akv_ref`Sequence[str]None`

Returns:

Raises:

resolve_env_akv_ref

resolve_env_akv_ref() → list[str] | None

Return the list of AKV secret URLs, or None when not configured.

Returns:

resolve_env_files

resolve_env_files() → Sequence[pathlib.Path] | None

Resolve environment file paths.

Returns:

resolve_initialization_scripts

resolve_initialization_scripts() → Sequence[pathlib.Path] | None

Resolve initialization script paths.

Returns:

resolve_initializers

resolve_initializers() → Sequence[PyRITInitializer]

Resolve initializer names to PyRITInitializer instances.

Uses the InitializerRegistry to look up initializer classes by name and instantiate them with optional arguments.

Returns:

Raises: