REFACTOR: Count execution units in pyrit_scan progress bar - #2549
Closed
Richard Lundeen (rlundeen2) wants to merge 1 commit into
Closed
Conversation
The scan progress bar counted techniques completed / total because the server only knew about attacks already persisted, so an attacks-based bar always read 100%. The backend now persists a normalized run plan, so total_attacks is a real planned total. Switch the bar to run.completed_attacks / run.total_attacks, relabel the output from 'techniques:' to 'units:', and delete the total_techniques / scenario_meta plumbing that only existed to compute the old ratio. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
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.
What changed
pyrit_scan runprints a live progress bar while it polls a scenario run. The bar counted techniques completed. It now counts execution units —completed_attacks/total_attacksonScenarioRunSummary— and the label changes fromtechniques:tounits:.An execution unit is
(atomic_group_id, seed_group_id): one objective run under one atomic attack group.Before:
After:
Why the technique-based bar existed, and why that constraint is gone
The removed code carried this comment:
Techniques were a proxy metric. The server could not report a planned attack total, so
total_attacksonly ever held the number of attacks already written to memory, andcompleted / totalwas always 1.The backend now persists a normalized run plan and computes canonical planned-vs-completed execution-unit counts.
total_attacksis now a real planned total, so the bar can measure the work the user actually cares about instead of a proxy.Deleted plumbing
total_techniquesandscenario_metawere threaded through_run_scenario_asyncand_poll_until_terminal_asynconly to compute the old ratio. Both are gone, along with themax(total_techniques, techniques_done)reconciliation that existed because a user-supplied technique could be an aggregate (single_turn) that expands into N concrete techniques on the server.This also removes a real inconsistency:
pyrit_shell.pycomputedtotal_techniquesfromrequest.techniquesonly, with noall_techniquesfallback, so the shell's bar could disagree withpyrit_scan's for aggregate techniques. Both now read the same server-computed counts.Files
pyrit/cli/_output.py—print_scenario_run_progressdrops thetotal_techniquesparameter and computes the bar from the run's unit counts.pyrit/cli/pyrit_scan.py— removes thetotal_techniques/scenario_metathreading.pyrit/cli/pyrit_shell.py— same call-site update in the interactive shell.tests/unit/cli/test_output.py,tests/unit/cli/test_pyrit_scan.py— updated assertions and call sites.Net: 20 insertions, 40 deletions. No frontend or server change; this reads fields that already exist on
ScenarioRunSummary.Tests
uv run pytest tests/unit/cli -q→ 516 passed.pre-commit run --all-files: the two failing hooks (Check Memory Migrations,ty) fail identically on the base branch without this change.