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.cli.pyrit_scan

PyRIT CLI - Command-line interface for running security scenarios.

This module provides the main entry point for the pyrit_scan command. It is a thin REST client that talks to the PyRIT backend server over HTTP. No heavy pyrit imports — all operations go through the REST API.

Functions

main

main(args: Optional[list[str]] = None) → int

Start the PyRIT scanner CLI.

Returns:

parse_args

parse_args(args: Optional[list[str]] = None) → Namespace

Parse command-line arguments (pass 1 — tolerant of scenario-declared flags).

Pass 1 uses parse_known_args so scenario-specific flags (e.g. --max-turns 7) don’t cause an error before we’ve had a chance to fetch the scenario’s declared parameters from the server. The unknown leftovers are stashed on the returned Namespace as _unknown_args so :func:_reparse_with_scenario_params can detect truly unknown flags when no scenario was specified.

ParameterTypeDescription
argsOptional[list[str]]Argument list (sys.argv[1:] when None). Defaults to None.

Returns:

validate_log_level_argparse

validate_log_level_argparse(value: Any) → int

Argparse-compatible wrapper around :func:validate_log_level.

Adapts the keyword-only validator to argparse’s positional type= calling convention and converts ValueError to :class:argparse.ArgumentTypeError.

ParameterTypeDescription
valueAnyLog level string supplied by argparse.

Returns:

Raises: