Implementation:0xSteph Pentest ai Chain Command
| Knowledge Sources | |
|---|---|
| Domains | CLI, Multi_Target, Authenticated_Scanning |
| Last Updated | 2026-10-23 00:00 GMT |
Overview
Concrete tool for running multiple authenticated scans sequentially, each with its own auth profile, provided by the pentest-ai CLI module.
Description
The cli.chain module implements the ptai chain command. It parses profile-name=target-url pairs, resolves each profile's credentials, runs authenticated scans sequentially, and stores findings per-engagement so they never bleed between scans. Each scan's result includes status (ok, auth_failed, failed, skipped), engagement ID, and finding summary. A Rich table renders the final summary.
Usage
Import this module when you need to run multi-target authenticated scans. Used by the ptai chain CLI command.
Code Reference
Source Location
- Repository: 0xSteph_Pentest_ai
- File: cli/chain.py
- Lines: 1-209
Signature
@dataclass
class ChainStep:
profile_name: str
target: str
def parse_pair(pair: str) -> ChainStep: ...
async def run_chain(steps: list[ChainStep]) -> list[dict]: ...
def render_summary(results: list[dict]) -> None: ...
def chain_command(pairs: list[str]) -> int: ...
Import
from cli.chain import chain_command, parse_pair, run_chain, ChainStep
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| pairs | list[str] | Yes | List of "profile-name=target-url" strings |
Outputs
| Name | Type | Description |
|---|---|---|
| results | list[dict] | One result per step with status, engagement_id, summary |
| exit code | int | 0 if all ok, 1 if any non-ok status, 2 on parse error |
Usage Examples
Run a Chain Scan
from cli.chain import chain_command
exit_code = chain_command([
"staging-acme=https://staging.acme.com",
"prod-internal=https://internal.corp.local",
"api-readonly=https://api.acme.com",
])
# Runs 3 sequential authenticated scans, each with its own profile.
# Prints a Rich summary table and returns exit code.
Parse Pairs Programmatically
from cli.chain import parse_pair, run_chain
steps = [parse_pair("juice-shop=http://localhost:3000")]
results = __import__("asyncio").run(run_chain(steps))
for r in results:
print(f" {r['profile_name']}: {r['status']}")