Repository navigation
FEAT: Delete saved registry entries (part 20) - #4071
Open
varunj-msft wants to merge 723 commits into
Open
varunj-msft wants to merge 723 commits into
varunj-msft wants to merge 723 commits into
Conversation
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Version-checked preset and suite deletes leave PermissionError unhandled, causing a 403 response that exposes server filesystem paths instead of a sanitized storage-unavailable 503.
2 open issues
What changed in this PR
Adds saved registry-entry deletion to CoPyRIT, building on persistence, ownership display, and restore recovery. The stacked changes also protect preset and suite deletes against stale versions.
Changes:
- Connects saved-entry management and restore recovery to backend routes and registry tables.
- Adds ownership, persistence eligibility, and protection against replacing saved entries.
- Updates version-checked deletion, isolated test storage, and user documentation.
| File | Description |
|---|---|
tests/unit/setup/test_targets_initializer.py |
Tests saved-target collision protection. |
tests/unit/setup/test_scorer_initializer.py |
Tests saved-scorer tagging protection. |
tests/unit/setup/test_converter_initializer.py |
Tests saved-converter replacement refusal. |
tests/unit/setup/test_configuration_loader.py |
Tests registry storage configuration. |
tests/unit/registry/test_scenario_suite_storage.py |
Tests stale suite-delete conflicts. |
tests/unit/registry/test_scenario_suite_registry.py |
Tests version-checked suite deletion. |
tests/unit/registry/test_scenario_preset_registry.py |
Tests version-checked preset deletion. |
tests/unit/registry/test_instance_registry.py |
Tests entry origins and replacement guards. |
tests/unit/registry/test_converter_registry.py |
Tests saved-name collision recording. |
tests/unit/registry/test_attack_technique_registry.py |
Tests saved-technique collision handling. |
tests/unit/backend/test_technique_edit_service.py |
Updates keyword-only service calls. |
tests/unit/backend/test_scenario_suite_service.py |
Tests delete-version forwarding. |
tests/unit/backend/test_scenario_suite_routes.py |
Tests delete conflicts and storage errors. |
tests/unit/backend/test_scenario_suite_execution_service.py |
Tests saved-entry launch conflict messages. |
tests/unit/backend/test_scenario_preset_service.py |
Tests stale preset-delete conflicts. |
tests/unit/backend/test_scenario_preset_routes.py |
Tests version checks and sanitized errors. |
tests/unit/backend/test_saved_entries.py |
Tests rejection of temporary dependencies. |
tests/unit/backend/test_mappers.py |
Tests origin and ownership mapping. |
tests/unit/backend/test_initializer_service.py |
Tests sanitized storage permission errors. |
tests/unit/backend/test_auth_middleware.py |
Tests current-user ID extraction. |
tests/unit/backend/test_analytics_benchmark.py |
Checks isolated recipe storage. |
tests/unit/backend/conftest.py |
Isolates saved entries in backend tests. |
tests/end_to_end/conftest.py |
Gives test backends fresh recipe storage. |
test_support/analytics_benchmark.py |
Configures benchmark recipe storage. |
pyrit/setup/initializers/tools.py |
Guards saved tool-entry collisions. |
pyrit/setup/initializers/targets.py |
Guards saved target-group collisions. |
pyrit/setup/initializers/scorers.py |
Prevents tagging saved substitutes. |
pyrit/setup/configuration_loader.py |
Adds registry recipe storage configuration. |
pyrit/score/true_false/local_refusal_classifier_scorer.py |
Declares persistence restriction. |
pyrit/score/true_false/audio_true_false_scorer.py |
Declares server-credential persistence restriction. |
pyrit/score/scorer.py |
Adds scorer persistence policy metadata. |
pyrit/score/float_scale/azure_content_filter_scorer.py |
Declares credential fallback behavior. |
pyrit/score/float_scale/audio_float_scale_scorer.py |
Declares audio scorer persistence restriction. |
pyrit/registry/scenario_suite_storage.py |
Supports conditional suite deletion. |
pyrit/registry/scenario_preset_storage.py |
Supports conditional preset deletion. |
pyrit/registry/components/scorer_registry.py |
Reserves the types instance name. |
pyrit/registry/components/scenario_suite_registry.py |
Forwards suite-delete versions. |
pyrit/registry/components/scenario_preset_registry.py |
Forwards preset-delete versions. |
pyrit/prompt_target/websocket_copilot_target.py |
Declares persistence restriction. |
pyrit/prompt_target/prompt_shield_target.py |
Declares credential and destination policies. |
pyrit/prompt_target/openai/openai_target.py |
Declares header, key, and endpoint policies. |
pyrit/prompt_target/litellm_chat_target.py |
Declares API-key fallback behavior. |
pyrit/prompt_target/hugging_face/hugging_face_chat_target.py |
Declares token and persistence restrictions. |
pyrit/prompt_target/http_target/http_target.py |
Disallows saving raw HTTP requests. |
pyrit/prompt_target/hack_a_prompt_target.py |
Declares session and cookie fallbacks. |
pyrit/prompt_target/github_copilot_target.py |
Declares token fallback behavior. |
pyrit/prompt_target/common/prompt_target.py |
Adds target persistence policy metadata. |
pyrit/prompt_target/azure_ml_chat_target.py |
Declares credential and endpoint policies. |
pyrit/prompt_target/azure_blob_storage_target.py |
Declares token and destination policies. |
pyrit/prompt_target/a2a_target.py |
Declares destination parameters. |
pyrit/models/catalog/target.py |
Adds target origin and ownership fields. |
pyrit/models/catalog/scorer.py |
Adds scorer origin and ownership fields. |
pyrit/models/catalog/__init__.py |
Exports recipe and restore models lazily. |
pyrit/converter/converter.py |
Adds credential fallback metadata. |
pyrit/converter/azure_speech_text_to_audio_converter.py |
Declares speech credential fallback. |
pyrit/converter/azure_speech_audio_to_text_converter.py |
Declares speech credential fallback. |
pyrit/backend/services/scenario_suite_service.py |
Passes conditional delete versions. |
pyrit/backend/services/scenario_suite_execution_service.py |
Exposes safe saved-entry conflict messages. |
pyrit/backend/services/scenario_run_service.py |
Reports initializer clashes with saved entries. |
pyrit/backend/services/scenario_preset_service.py |
Passes conditional delete versions. |
pyrit/backend/routes/techniques.py |
Adds ownership and persistence handling. |
pyrit/backend/routes/targets.py |
Adds ownership and persistence handling. |
pyrit/backend/routes/scorers.py |
Adds ownership and persistence handling. |
pyrit/backend/routes/scenarios.py |
Documents saved-entry launch conflicts. |
pyrit/backend/routes/scenario_suites.py |
Handles delete versions and storage errors. |
pyrit/backend/routes/scenario_presets.py |
Handles delete versions and storage errors. |
pyrit/backend/routes/restore_failures.py |
Exposes restore failures and retry. |
pyrit/backend/routes/initializers.py |
Sanitizes storage error reporting. |
pyrit/backend/routes/common.py |
Shares ownership and persistence-error helpers. |
pyrit/backend/models/techniques.py |
Adds persistence validation and ownership fields. |
pyrit/backend/models/targets.py |
Adds persistence validation and eligibility fields. |
pyrit/backend/models/scorers.py |
Adds persistence request validation. |
pyrit/backend/models/scenario_suites.py |
Documents delete-version use. |
pyrit/backend/models/scenario_presets.py |
Documents delete-version use. |
pyrit/backend/models/saved_entries.py |
Defines saved-file management responses. |
pyrit/backend/models/converters.py |
Adds persistence and ownership fields. |
pyrit/backend/middleware/runtime.py |
Admits recovery and saved-entry management routes. |
pyrit/backend/middleware/auth.py |
Exposes the current user's object ID. |
pyrit/backend/mappers/technique_mappers.py |
Maps technique origin and ownership. |
pyrit/backend/mappers/target_mappers.py |
Maps target origin and ownership. |
pyrit/backend/mappers/converter_mappers.py |
Maps converter origin and ownership. |
pyrit/backend/main.py |
Registers recovery and saved-entry routes. |
frontend/src/utils/registryOrigin.ts |
Shares origin labels and ownership captions. |
frontend/src/utils/registryName.ts |
Suggests valid, available registry names. |
frontend/src/utils/registryName.test.ts |
Tests registry-name validation and suggestions. |
frontend/src/test-utils/targetFixtures.ts |
Adds ownership and origin fixture fields. |
frontend/src/services/errors.ts |
Recognizes persistence refusal responses. |
frontend/src/services/errors.test.ts |
Tests persistence refusal detection. |
frontend/src/services/api.ts |
Adds management calls and delete versions. |
frontend/src/services/api.test.ts |
Tests versioned delete requests. |
frontend/src/hooks/useRuntime.styles.ts |
Styles restore-failure lists and delete controls. |
frontend/src/components/Techniques/TechniqueEditor.test.tsx |
Updates converter save-button expectations. |
frontend/src/components/ScenarioSuites/ScenarioSuiteLibrary.tsx |
Handles delete conflicts and restores focus. |
frontend/src/components/ScenarioSuites/ScenarioSuiteLibrary.test.tsx |
Tests conflict reload and focus behavior. |
frontend/src/components/ScenarioPresets/ScenarioPresetLibrary.tsx |
Handles delete conflicts and restores focus. |
frontend/src/components/ScenarioPresets/ScenarioPresetLibrary.test.tsx |
Tests conditional deletion and focus recovery. |
frontend/src/components/Registry/TechniqueRegistry.tsx |
Adds ownership filtering and saved deletion. |
frontend/src/components/Registry/ScorerRegistry.tsx |
Adds ownership filtering and saved deletion. |
frontend/src/components/Registry/ScorerRegistry.test.tsx |
Tests origins, ownership filters, and delete controls. |
frontend/src/components/Registry/ScenarioPresetRegistry.test.tsx |
Expects versioned preset deletion. |
frontend/src/components/Registry/SavedBy.tsx |
Renders shared ownership captions. |
frontend/src/components/Registry/SavedBy.styles.ts |
Styles ownership captions. |
frontend/src/components/Registry/OriginBadge.tsx |
Displays registry-entry origins. |
frontend/src/components/Registry/DeleteSavedEntryButton.styles.ts |
Styles delete-dialog content. |
frontend/src/components/Registry/ConverterRegistry.tsx |
Separates saved deletion from live removal. |
frontend/src/components/Converters/SaveConverterDialog.tsx |
Clarifies that converter copies are temporary. |
frontend/src/components/Converters/SaveConverterDialog.test.tsx |
Tests temporary-copy wording. |
frontend/src/components/Config/TargetTable.tsx |
Adds origins, ownership filtering, and deletion. |
frontend/src/components/Config/TargetTable.styles.ts |
Styles ownership and filter controls. |
frontend/src/components/Config/TargetConfig.tsx |
Refreshes targets after deletion. |
frontend/src/App.tsx |
Places the runtime banner inside the theme. |
frontend/playwright.config.ts |
Isolates seeded backend recipe storage. |
frontend/e2e/fixtures/scenario_dataset_backend.py |
Forwards delete versions through the storage guard. |
frontend/e2e/fixtures/manual_send_backend.py |
Uses temporary recipe storage. |
frontend/e2e/config.spec.ts |
Tests target saving and ownership filtering. |
frontend/e2e/_targets.ts |
Adds ownership and origin mock fields. |
doc/gui/0_gui.md |
Documents saving, ownership, deletion, and recovery. |
doc/getting_started/pyrit_conf.md |
Documents recipe storage and restore recovery. |
.pyrit_conf_example |
Adds registry recipe storage guidance. |
Review effort: Balanced
| status_code=status.HTTP_409_CONFLICT, | ||
| detail=f"Scenario preset '{name}' changed since it was read; re-read it and retry", | ||
| ) from None | ||
| except (AzureError, TimeoutError) as exc: |
Contributor
Author
| status_code=status.HTTP_409_CONFLICT, | ||
| detail=f"Scenario suite '{name}' changed since it was read; re-read it and retry", | ||
| ) from None | ||
| except (AzureError, TimeoutError) as exc: |
Contributor
Author
varunj-msft
requested review from
hannahwestra25 and
Richard Lundeen (richlundeen)
November 8, 2026 23:56
This was referenced Nov 9, 2026
This was referenced Nov 9, 2026
# Conflicts: # frontend/src/components/Config/CreateTargetDialog.tsx
# Conflicts: # doc/getting_started/pyrit_conf.md # pyrit/backend/services/target_service.py
Configuration lists the failures but can't fix them here, so the banner says to view them there and fix or delete the files in registry_recipes_source. It uses the multiline layout, since its longer text replaces the status after the bar first lays out.
…on a narrow screen
# Conflicts: # frontend/src/services/api.ts # pyrit/backend/README.md
The local-folder test built the private encoder itself, so it passed even if the scorer stopped passing model_path on. It now builds the scorer with model_path or a Hub model_id and calls load_model_async.
Only registry_recipe_save and its tests use it, and it isn't exported, so it keeps the underscore it had before this change.
not_saveable_reason is the cause alone, and the GUI already shows that the converter can't be saved, so the reason no longer starts with "'X' can't be saved."
An optional file parameter sent as null or an empty string means no file, so saving leaves it out, as restore builds the converter, instead of refusing it as an uploaded file.
POST /api/converters/saveability runs the checks saving runs before the converter is built, through the same service function as saving, and the New Converter dialog asks it the way the New Target dialog does instead of keeping its own copy of those rules. The catalog's type-level reason and the refused-save fallback stay. An optional file parameter typed Path | None counts as an upload too, so a file the user removed is left out.
RegistryIdentityRow puts the name cell's badges in one wrapper under the name, the layout the Targets table had, so the Converters, Scorers, and Targets tables line them up however long a name is.
Saving a converter's changed settings under a new name makes a Temporary copy, while Save Converter now makes one that comes back after a restart. The menu item and dialog say Add to registry, with an Add button, so the two aren't confused.
Fluent let the dialog body grow past the surface's height less its padding, so with the Temporary warning shown a long form pushed Create as Temporary over the dialog's bottom edge. The body now has the surface's height and the form scrolls, as in the attack details dialog.
check_saved_technique_async runs the checks restore runs on a technique: the attack type, its parameters' credentials, addresses, and environment settings, and the entries the technique names, which it lists with the same recipe_references helper restore uses. The technique service calls it instead of its own copy of the rule, so a notebook can check a technique too. refuse_temporary_entries is private again and no longer exported.
POST /api/techniques/saveability answers with check_saved_technique_async, the check saving runs, and the technique editor asks it the way the target and converter dialogs do instead of keeping its own copy of the Temporary converter and target rule. The refused-save fallback stays for anything that changes in between.
register_from_factories and register_technique now refuse a technique whose name or tag would select it in a saved technique's place, as register_runtime does, and record the clash so a script that catches the error still can't launch. The bulk path checks every factory before it registers any. Both paths and _check_available share one definition of a clash with a saved technique.
The Registry name hint repeated the rule the name error gives, in other words and without the 64-character limit. The hint is gone, so the error alone states the rule. The rule only applies to a technique that's saved, so a standing hint would also have been wrong for a Temporary one.
A 409 from saving a technique now gives errors naming the field that clashes, body.name or body.tags, and the technique editor shows the conflict on that field. A tag conflict no longer marks Registry name, which is correct. A conflict without a field still shows above the form.
… be saved The README said every added technique is runtime-only. Only Temporary techniques go away; a saved one comes back, and it's removed by deleting techniques/<name>.json under registry_recipes_source and restarting. The list of reasons a technique can't be saved now has all of them, including a credential in the attack parameters.
Fluent let the dialog body grow past the 90vh surface less its padding, so with the Temporary warning shown, Create as Temporary ended below the viewport at 390x844 and 390x700 and crossed the card's edge at 1440x700 and 1280x720. The body now has the surface's height and the form scrolls, as in the converter dialog. A mocked browser test checks the button at those four sizes, and that the Techniques table lines up its origin badges under every name.
# Conflicts: # frontend/e2e/registry.spec.ts
# Conflicts: # pyrit/backend/services/technique_service.py # pyrit/registry/registry_recipe_save.py # tests/unit/registry/test_registry_recipe_save.py
A 409 for an entry the recipe names that was deleted while it was being saved is about neither the name nor a tag, so it gives no field errors, and the technique editor shows it above the form instead of on Registry name.
The 409 that says which field clashes is now a TechniqueConflictResponse with FieldError entries, as the 400 for an entry that can't be saved goes through NotSaveableProblemDetail, so the exception's message reaches the response through a model rather than straight from the exception (CodeQL's stack trace exposure alert). The JSON is the same.
# Conflicts: # pyrit/backend/routes/techniques.py
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
This is one of the changes for saving Registry entries across restarts. It builds on #3965 (the list of entries that couldn't be restored, merged) and the version-checked deletes from #3656, also on
main. Until the earlier PRs merge, the diff here also shows their changes.A saved target, converter, scorer or technique couldn't be deleted from the app. The only way was to delete its file under
registry_recipes_sourceand restart, even for an entry that failed to restore and kept the backend from being ready.GET /api/saved-entries/{kind}/{name}describes a saved file: its version, why it can't be used if it can't, and whether you may change it.DELETE /api/saved-entries/{kind}/{name}?expected_version=<version>deletes the file and removes the entry it restored.kindistargets,converters,scorersortechniques.PYRIT_ALLOW_UNAUTHENTICATED_ADMIN=true. Who saved an entry stays in its file as attribution only. This replaces the earlier owner-or-admin rule, following the review on FEAT: Show who saved each target and list only your own (part 10) #4028.DELETE /api/converters/{id}still refuses a saved converter (409), and its message points to the new route.What stays the same: saving and restoring work as before, except that a save waits for a delete in progress and checks again that what it names still comes back.
DELETE /api/converters/{id}still removes Temporary and startup converters from the live registry. Startup entries have no saved file, so they can't be deleted here (404).Screenshots: Delete on a saved target in the Targets table, and the dialog.


Not covered:
DELETE /api/converters/{id}.