Repository navigation
FEAT: Read saved registry recipes - #3892
Open
varunj-msft wants to merge 15 commits into
Open
varunj-msft wants to merge 15 commits into
varunj-msft wants to merge 15 commits into
Conversation
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues require changes to the registry recipe models or storage reader.
No open issues 🎉
What changed in this PR
Adds the models and storage reader needed to preserve registry entries across restarts. This second stacked PR builds on #3891’s document-listing support; entry rebuilding and startup restoration remain for later PRs.
Changes:
- Defines versioned component and technique recipes, plus restore-report types with JSON-safe text.
- Reads recipes from per-registry local or Azure Blob folders, preserving SAS queries and reporting invalid, unreadable, newer-format, and ignored files.
- Adds unit coverage for parsing, versions, validation, storage failures, and report serialization without changing existing callers.
| File | Description |
|---|---|
tests/unit/registry/test_registry_recipe_storage.py |
Tests recipe loading, validation, versions, Blob paths, and report serialization. |
tests/unit/registry/test_file_document_storage.py |
Tests issue-aware local and Blob listings and safe error messages. |
pyrit/registry/registry_recipe_storage.py |
Adds per-registry storage, recipe parsing, and failure reporting. |
pyrit/registry/file_document_storage.py |
Adds issue-aware listings while retaining legacy listing behavior. |
pyrit/models/request_limits.py |
Adds the shared technique-description text limit. |
pyrit/models/catalog/registry_recipe.py |
Defines recipe schemas, references, and restore-report models. |
pyrit/models/catalog/__init__.py |
Exposes the new models through lazy exports. |
Review effort: Balanced
…s that can't be checked
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's the second of four stacked PRs and builds on #3891. Until #3891 merges, the diff here also shows its changes.
Problem. There's no file format or storage for a saved target, converter, scorer or technique.
Change.
pyrit/models/catalog/registry_recipe.py: the recipe models, exported frompyrit.models.catalog.schema_version,class_module,class_nameandparams.credentialsis reported, not silently read.pyrit/models/request_limits.py: addsMAX_TEXT_LENGTHfor the technique description. FIX: Apply the request limits to request fields added since the last limits PR #3595 adds the same line, so the two merge cleanly; until it lands,backend/models/common.pykeeps its own copy of the same value.pyrit/registry/registry_recipe_storage.py:RegistryRecipeStorage, aFileDocumentStoragewith one folder per registry (targets/,converters/,scorers/,techniques/) under one source.list_recipes()uses the listing from the previous PR. It returns the parsed recipes with their versions (the SHA-256 of the bytes), a failure for each unreadable, invalid or newer-format file, and the ignored files.\udcffescape inside a recipe, so the report can always be sent as JSON. Valid text is unchanged.What stays the same. Nothing calls this yet; the next PR rebuilds entries from these recipes. No API, config or behavior change.
Tests and Documentation
tests/unit/registry/test_registry_recipe_storage.py: recipes and their versions, field limits and unknown fields, failures for unreadable, invalid and newer-format files, ignored names, Blob folders that keep a SAS token in the query, and report text that isn't UTF-8 (escaped only when sent as JSON; models keep the text they were given; valid text unchanged).pytest tests/unit/registry tests/unit/models -n 4: 3,459 passedpre-commit run --from-ref origin/main --to-ref HEAD: passed