MAINT: Extract technique factory resolution from MatrixAtomicAttackBuilder (#2869) - #2879
Open
Vardhman Gupta (Kaap10) wants to merge 3 commits into
Open
Vardhman Gupta (Kaap10) wants to merge 3 commits into
Vardhman Gupta (Kaap10) wants to merge 3 commits into
Conversation
3 tasks
Contributor
Author
|
Hi Roman Lutz (@romanlutz), this PR extracts technique factory resolution into a dedicated module per #2869 with full test parity. Whenever you have some time, could you please take a look and approve the workflow run? Thanks! |
Roman Lutz (romanlutz)
requested changes
Sep 28, 2026
Contributor
Author
|
Thanks for the review! I have addressed both points in the latest commit (
All linting checks ( |
This branch has not been deployed
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
Fixes #2869
While exploring technique resolution across different scenario architectures, I noticed that
pyrit/scenario/core/matrix_atomic_attack_builder.pycombined both matrix combinatorial expansion and generic technique factory resolution/validation logic (resolve_technique_factories,resolve_technique_factories_for_techniques, andTechniqueResolutionError).As highlighted in the builder's module docstring, scenarios of different shapes (such as adaptive scenarios, composite builders, or per-objective builders) also need technique resolution from
AttackTechniqueRegistryandextra_factories, but they shouldn't need to import or couple withmatrix_atomic_attack_builder.py.This PR extracts the technique resolution and missing technique validation logic into a dedicated private helper module:
pyrit/scenario/core/_technique_resolution.pycontainingTechniqueResolutionError,resolve_technique_factories, andresolve_technique_factories_for_techniqueswith complete Google/Sphinx style docstrings.pyrit/scenario/core/matrix_atomic_attack_builder.py(with explicit__all__) and registered lazy exports inpyrit/scenario/core/__init__.pyto ensure complete backward compatibility for external callers and legacy imports.pyrit/scenario/core/scenario.pyto import directly from_technique_resolution.Tests and Documentation
tests/unit/scenario/core/test_technique_resolution.pycovering context resolution, sequence resolution, error deduplication in first seen order,ValueErrorinheritance, andextra_factoriesoverrides.tests/unit/scenario/core/test_matrix_atomic_attack_builder.py.tests/unit/scenario/test_default_run_size_estimates.pyto point to_technique_resolution.pytest tests/unit/scenario/), all 1,268 unit tests passed.ruff checkandruff format, all checks passed with 0 errors.