-
Notifications
You must be signed in to change notification settings - Fork 801
FEAT Plug-in mechanism for private scenarios #2131
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
ValbuenaVC
wants to merge
24
commits into
microsoft:main
Choose a base branch
from
ValbuenaVC:vvalbuena-microsoft-plugin-mechanism
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
9f409ab
feat(setup): add plug-in loading to initialize_pyrit_async
c7a7528
Merge branch 'main' into vvalbuena-microsoft-plugin-mechanism
ValbuenaVC e7d63cf
Merge branch 'main' into vvalbuena-microsoft-plugin-mechanism
ValbuenaVC eca5928
Potential fix for pull request finding
ValbuenaVC 0b11b6c
Merge branch 'main' into vvalbuena-microsoft-plugin-mechanism
ValbuenaVC 8781038
Merge branch 'main' into vvalbuena-microsoft-plugin-mechanism
ValbuenaVC e6159e5
test(setup): verify plug-in scenarios are discovered end-to-end
f8e761d
fix(setup): restore overwritten registry entries on plug-in rollback
ed3fc0d
refactor(setup): extract plug-in wheels with safe_extract_zip
fb822e0
perf(setup): run blocking plug-in extraction off the event loop
95de68c
feat(setup): add granular PluginLoadError subclasses
c108578
fix(setup): use a unique temp dir for plug-in wheel extraction
b551008
Merge branch 'main' into vvalbuena-microsoft-plugin-mechanism
ValbuenaVC c028f8b
refactor(setup): rename plugin_fail_open to plugin_accept_load_failures
67f8a85
Merge commit 'b55100804be2f4fae26d619cbd5b072e104a94ce' into vvalbuen…
067ffba
Merge branch 'main' into vvalbuena-microsoft-plugin-mechanism
ValbuenaVC 2ae6c55
feat(setup): configure plug-ins in .pyrit_conf with multi-plug-in sup…
b21f856
Merge commit '067ffba6461c6e89590a3d369a3d5bcc408508a3' into vvalbuen…
21ebf36
Merge branch 'main' into vvalbuena-microsoft-plugin-mechanism
ValbuenaVC 466679a
Merge commit '21ebf36815e93891ef55221912fee2345bd311c9' into vvalbuen…
88bd76a
feat(registry): auto-register external plug-in Scenario subclasses
b177f49
feat(setup): tolerate plug-in version drift and re-extract stale wheels
1538e6e
test(setup): cover plug-in auto-registration, discovery, instantiate,…
bbd3da8
Merge branch 'main' into vvalbuena-microsoft-plugin-mechanism
ValbuenaVC File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| # Keeps the .plugin/ directory in version control while its contents stay ignored. | ||
| # PyRIT extracts plug-in wheels here at runtime (see PLUGIN_WHEEL). |
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -109,6 +109,35 @@ def _get_registry_name(self, cls: type[Scenario]) -> str: | |
| return relative | ||
| return class_name_to_snake_case(cls.__name__, suffix="Scenario") | ||
|
|
||
| def _external_registry_name(self, cls: type[Scenario], *, package_name: str) -> str: | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. could we normalize this with how initializers do it since I think they discover filepaths? |
||
| """ | ||
| Key a plug-in scenario by its module path within the plug-in package. | ||
|
|
||
| Mirrors the built-in dotted-name scheme (module path relative to the scenarios | ||
| package) so plug-in scenarios read like built-ins and same-named scenarios in | ||
| different submodules do not collide on a bare class name. The name is the class's | ||
| module relative to the plug-in's top-level ``package_name`` with a leading | ||
| ``scenario.scenarios.`` / ``scenarios.`` segment stripped to match built-in style; | ||
| it falls back to the suffix-stripped snake_case class name when no module context | ||
| is available. | ||
|
|
||
| Args: | ||
| cls (type[Scenario]): The plug-in scenario class. | ||
| package_name (str): The plug-in's top-level package name. | ||
|
|
||
| Returns: | ||
| str: The dotted registry name for the plug-in scenario. | ||
| """ | ||
| module = cls.__module__ or "" | ||
| prefix = f"{package_name}." | ||
| relative = module[len(prefix) :] if module.startswith(prefix) else module | ||
| for marker in ("scenario.scenarios.", "scenarios."): | ||
| index = relative.find(marker) | ||
| if index != -1: | ||
| relative = relative[index + len(marker) :] | ||
| break | ||
| return relative or class_name_to_snake_case(cls.__name__, suffix="Scenario") | ||
|
|
||
| def _build_metadata(self, name: str, cls: type[Scenario]) -> ScenarioMetadata: | ||
| """ | ||
| Build metadata for a Scenario class. | ||
|
|
||
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.