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) → intStart the PyRIT scanner CLI.
Returns:
int— Exit code (0 for success, 1 for error).
parse_args¶
parse_args(args: Optional[list[str]] = None) → NamespaceParse 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.
| Parameter | Type | Description |
|---|---|---|
args | Optional[list[str]] | Argument list (sys.argv[1:] when None). Defaults to None. |
Returns:
Namespace— Parsed command-line arguments.
validate_log_level_argparse¶
validate_log_level_argparse(value: Any) → intArgparse-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.
| Parameter | Type | Description |
|---|---|---|
value | Any | Log level string supplied by argparse. |
Returns:
int— Validated log level as aloggingmodule constant.
Raises:
argparse.ArgumentTypeError— Ifvalueis not a valid log level.