FEAT: Convert pyrit_scan mode-flags to subcommands + stale docs corrections - #2401
Open
Justin Song (jsong468) wants to merge 3 commits into
Open
FEAT: Convert pyrit_scan mode-flags to subcommands + stale docs corrections#2401Justin Song (jsong468) wants to merge 3 commits into
Justin Song (jsong468) wants to merge 3 commits into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
pyrit_scan's mode-flags into argparse subcommands (verbs):run,list-scenarios/list-initializers/list-targets/list-converters/list-datasets,add-initializer,scenario-results,scenario-history,start-server,stop-server.This mirrors
pyrit_shell1:1 and lets argparse enforce which flags belong to whichcommand, deleting hand-written validation.
runowns the scenario positional, run flags, and the dynamically-injectedscenario-declared flags (two-pass parse: generic parse, fetch scenario metadata,
re-parse with the scenario's flags attached to the
runsub-parser).form is rewritten to its verb with a deprecation warning (
removed_in="1.3.0"), keepingthe old surface working for one release. Consolidating it in one function makes the
eventual removal a clean single-commit deletion.
scenario-resultsis the one exception— it shipped only days ago with no released flag form, so it's verb-only.
pyrit_scan <scenario>→run <scenario>, with a deprecation warning), since running a scenario is the mostcommon invocation and breaking it hard would defeat a gentle migration. Trade-off: a
mistyped verb is read as a scenario name and surfaces as a server-side "scenario not
found" — acceptable and close to today's behavior.
1.3.0lands): this PR is thestructural change; the legacy shim then deletes on its own.
_is_command_specified,_validate_results_flags) — subparsers make them unnecessary.Key design decisions
(
--server-url,--config-file,--log-level,--request-timeout,--start-server,--startup-timeout) are inherited by every subparser viaparents=[global_parser],which avoids argparse's default-clobbering. Natively they work after the verb; the
shim reorders a global placed before a verb so both orderings work (and a leading
global isn't misread as an implicit scenario name).
--start-serverstays a global modifier and a verb. It also means "auto-start theserver before running this other command," which is cross-cutting and can't live in one
verb; the standalone
start-serververb covers the explicit "just start it" case.list-*verbs (not a singlelist <what>) to match the shell'sdo_list_*commands exactly.Tests
test_pyrit_scan.pyaround verbs:TestParseArgsandTestMainuse the verbforms; added
TestLegacyArgvShimcovering legacy flags, implicit-run, standalone--start-server, and global-before-verb reordering.Documentation
(
doc/scanner/1_pyrit_scan,doc/scanner/2_pyrit_shell,doc/code/scenarios/2_custom_scenario_parameters, and related pages).--initialization-scriptsflag and
--initializersonlist-*commands; documented that custom scenarios andconverters are loaded via the config file's
initialization_scriptssection (run by thebackend at startup), and that
list-scenarios(notrun --help) is the path to discovera scenario's declared parameters.
.py/.ipynbdoc sources in sync.