Repository navigation
MAINT: Fix backend unsound assignments (UA-4) - #4537
Merged
Roman Lutz (romanlutz) merged 5 commits intoNov 22, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The casts leave operator and operation types unchecked, allowing numeric YAML values to cause runtime or response-validation failures; boundary validation and rejected-input tests are needed.
1 open issue
What changed in this PR
This PR advances UA-4 of #4402 by tightening backend types and removing backend files from the temporary unsound-assignment override.
Changes:
- Refines return and collection types and adds explicit casts for app state and library values.
- Validates Docker build metadata for
/api/version, preserving fallback behavior for malformed metadata. - Adds regression tests for metadata parsing and version responses.
| File | Description |
|---|---|
tests/unit/backend/test_api_routes.py |
Tests metadata validation, extra-key filtering, and fallback responses. |
pyrit/backend/services/target_service.py |
Narrows target lookup to PromptTarget | None. |
pyrit/backend/services/scenario_service.py |
Explicitly types the estimate-task container and fallback. |
pyrit/backend/services/finding_export.py |
Casts the document library’s paragraph return value. |
pyrit/backend/services/attack_service.py |
Explicitly types empty message-piece lists. |
pyrit/backend/routes/version.py |
Validates build metadata and casts app-state defaults. |
pyrit/backend/routes/targets.py |
Casts the configured upload-directory value. |
pyrit/backend/middleware/runtime.py |
Casts the app-state runtime lifecycle reference. |
pyproject.toml |
Removes backend entries from the temporary type-checking override. |
Review effort: Balanced
BuildInfo as a strict pydantic model replaces the TypedDict plus per-key isinstance checks; ValidationError is caught by the existing fallback in get_version_async. Explicit JSON nulls now validate instead of rejecting the whole file, which produces the same response values. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Roman Lutz (romanlutz)
approved these changes
Nov 22, 2026
Roman Lutz (romanlutz)
enabled auto-merge
November 22, 2026 07:20
Roman Lutz (romanlutz)
added a commit
to romanlutz/PyRIT
that referenced
this pull request
Nov 23, 2026
Resolve the pyproject.toml conflict with UA-3, UA-4, UA-5 and UA-7 (microsoft#4520, microsoft#4537, microsoft#4519, microsoft#4517): each change removes its own files from the temporary unsound-assignment override, so the merged list drops those and the GCG entries and keeps only the UA-6 files. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.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.

UA-4 for #4402: fixes the unsound-assignment findings in
pyrit/backendand removes the backend files from the temporary override inpyproject.toml, so the rule now checks them.routes/version.py: fixes a real bug in/api/versionalong the way, with new tests intests/unit/backend/test_api_routes.py.prompt_generation_service.pyneeded no changes and passes with the override removed.