FEAT: Security & Azure deployment for CoPyRIT GUI#1554
Open
adrian-gavrila wants to merge 175 commits intomicrosoft:mainfrom
Open
FEAT: Security & Azure deployment for CoPyRIT GUI#1554adrian-gavrila wants to merge 175 commits intomicrosoft:mainfrom
adrian-gavrila wants to merge 175 commits intomicrosoft:mainfrom
Conversation
- Add run_initializers_async to pyrit.setup for programmatic initialization - Switch AIRTInitializer to Entra (Azure AD) auth, removing API key requirements - Add --config-file flag to pyrit_backend CLI - Use PyRIT configuration loader in FrontendCore and pyrit_backend - Update AIRTTargetInitializer with new target types Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Add conversation_stats model and attack_result extensions - Add get_attack_results with filtering by harm categories, labels, attack type, and converter types to memory interface - Implement SQLite-specific JSON filtering for attack results - Add memory_models field for targeted_harm_categories - Add prompt_metadata support to openai image/video/response targets - Fix missing return statements in SQLite harm_category and label filters Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Add attack CRUD routes with conversation management - Add message sending with target dispatch and response handling - Add attack mappers for domain-to-DTO conversion with signed blob URLs - Add attack service with video remix support and piece persistence - Expand target service and routes with registry-based target management - Add version endpoint with database info Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Add attack-centric chat UI with multi-conversation support - Add conversation panel with branching and message actions - Add attack history view with filtering - Add labels bar for attack metadata - Add target configuration with create dialog - Add message mapper utilities for backend/frontend translation - Add video playback support with signed blob URLs - Add InputBox with attachment support and auto-expand - Update dev.py with --detach, logs, and process management - Add e2e tests for chat, config, and flow scenarios Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…ssibility Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
… into romanlutz/backend-attack-api
- Rename supports_multiturn_chat to supports_multi_turn to align with TargetCapabilities field - Use target_obj.capabilities.supports_multi_turn instead of isinstance check - Update tests to set capabilities on mock targets Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…_async Reverts the separate run_initializers_async function and restores the original pattern where run_scenario_async calls initialize_pyrit_async a second time with initializers. This avoids a larger refactor. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Catch ValueError in get_conversation_messages route, return 400 - Fix target_registry_name field description - Simplify redundant except (ValueError, Exception) to except Exception - Fix docstring: converter_classes -> converter_types - Fix test assertions: converter_types -> converter_classes (matches memory API) - Remove dead tests for deleted helper methods - Restore azure_openai_video target config to match main Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Move _inject_video_id_from_history and _strip_video_pieces methods from AttackService to OpenAIVideoTarget where they belong - Update _validate_request to accept video_path pieces and check for video_path+image_path conflicts - Add ValueError when video_path is present but no video_id can be resolved - Add 7 unit tests for the inject/strip logic - Remove video-specific logic from attack_service._send_and_store_message Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Change getApiScopes to request https://graph.microsoft.com/User.Read - Reuse shared getApiScopes in api.ts instead of duplicate - Update backend token validation audience to graph.microsoft.com - Update test assertions for new scope - Enables groups overage resolution via Graph API Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
ValbuenaVC
reviewed
Apr 1, 2026
- Replace toBeInTheDocument with toBeVisible for user-facing assertions - Add afterEach restoreAllMocks for full test isolation - Refactor AuthConfig from global cache to React Context - Rename useMsal instance to msalInstance for clarity - Extract _authenticate_request_async from dispatch method - Replace magic number with removeprefix for Bearer token parsing - Rename overage methods/comments for clarity - Add _client_id usage comment in auth middleware - Clarify .azure directory mount in Docker run script - Standardize Entra ID vs Azure terminology in docs - Expand acronyms and add links in infra README - Add what-if preview section to infra README Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Extract AuthConfigContext to separate file (react-refresh/only-export-components) - Replace ghcr.io/astral-sh/uv container image with install script to comply with Microsoft container security policy (CSSC) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds Entra ID (MSAL PKCE) authentication plus backend JWT validation and security headers for the CoPyRIT GUI, and introduces Azure Container Apps IaC + an Azure DevOps deployment pipeline to support hardened deployments.
Changes:
- Add frontend MSAL PKCE auth flow and attach Bearer tokens to API requests; add backend JWT validation and security headers middleware.
- Add Azure Container Apps Bicep templates + deployment documentation and example parameters.
- Update Docker startup/config mounting and introduce an ADO pipeline for build/push/deploy.
Reviewed changes
Copilot reviewed 31 out of 33 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| uv.lock | Adds PyJWT dependency to lockfile. |
| pyproject.toml | Adds PyJWT dependency for backend JWT validation. |
| pyrit/backend/main.py | Wires in security headers + Entra auth middleware; tightens CORS; disables docs in prod. |
| pyrit/backend/middleware/init.py | Exposes SecurityHeadersMiddleware. |
| pyrit/backend/middleware/security_headers.py | Adds CSP/HSTS/etc security header injection middleware. |
| pyrit/backend/middleware/auth.py | Adds Entra JWT validation + group authorization middleware. |
| pyrit/backend/routes/auth.py | Adds /api/auth/config endpoint to serve non-secret MSAL config. |
| infra/README.md | Adds deployment guide for Azure Container Apps hardened setup. |
| infra/parameters.example.json | Adds example deployment parameters. |
| infra/main.bicep | Adds Bicep template for ACA, MI, KV secret refs, logging, optional private networking. |
| infra/main.json | Generated ARM JSON for the Bicep template. |
| gui-deploy.yml | Adds Azure DevOps pipeline to build/push image and deploy to test/prod. |
| frontend/src/main.tsx | Wraps app in AuthProvider. |
| frontend/src/auth/msalConfig.ts | Adds runtime MSAL configuration + API scope helpers. |
| frontend/src/auth/msalConfig.test.ts | Adds unit tests for MSAL config helpers. |
| frontend/src/auth/AuthConfigContext.ts | Adds context for auth config values. |
| frontend/src/auth/AuthProvider.tsx | Adds MSAL initialization/login redirect wrapper for the app. |
| frontend/src/auth/AuthProvider.test.tsx | Adds tests for auth init and auth-disabled behavior. |
| frontend/src/services/api.ts | Adds token acquisition + Authorization header injection + 401 retry. |
| frontend/src/services/api.test.ts | Updates tests for async request interceptor. |
| frontend/src/App.tsx | Wires MSAL instance into API client from within the app. |
| frontend/src/App.test.tsx | Mocks MSAL hooks and API client wiring in tests. |
| frontend/package.json | Adds MSAL deps and related test tooling deps. |
| frontend/package-lock.json | Updates lockfile for new dependencies. |
| frontend/.npmrc | Pins npm registry and enables legacy peer deps. |
| build_scripts/prepare_package.py | Changes npm install to use --legacy-peer-deps. |
| docker/start.sh | Writes .env from PYRIT_ENV_CONTENTS; starts backend with args for GUI/AzureSQL/initializers. |
| docker/run_pyrit_docker.py | Mounts .pyrit_conf and ~/.azure; enables interactive -it. |
| docker/QUICKSTART.md | Updates Docker quickstart with new mounting + auth notes. |
| docker/Dockerfile | Requires explicit BASE_IMAGE build arg (no default). |
| docker/docker-compose.yaml | Mounts .pyrit_conf and ~/.azure into GUI container. |
| .pyrit_conf_example | Updates example config (currently duplicates operator/operation). |
| .devcontainer/Dockerfile | Changes uv installation method in devcontainer image. |
Files not reviewed (1)
- frontend/package-lock.json: Language not supported
Comments suppressed due to low confidence (1)
frontend/package.json:33
@azure/msal-react@^5.0.7declares a peer dependency on React^19.2.1(see package-lock), but this project depends on React^18.3.1. The current workaround (legacy-peer-deps) bypasses npm's resolver but leaves an unsupported dependency combination that can break at runtime. Either pin@azure/msal-reactto a version that supports React 18, or upgrade React (and related tooling) to the required major version.
"dependencies": {
"@azure/msal-browser": "^5.5.0",
"@azure/msal-react": "^5.0.7",
"@fluentui/react-components": "^9.54.0",
"@fluentui/react-icons": "^2.0.258",
"axios": "^1.13.5",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-error-boundary": "^6.1.1"
},
- Remove useMsal() from App.tsx (crashes when auth is disabled, already handled by AuthProvider) - Add test case for auth-disabled rendering path - Rename allowedGroupId to allowedGroupIds to match backend response - Add api:// prefix to MSAL scope for correct Application ID URI - Document known limitation in Graph overage fallback (token audience mismatch) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Remove duplicate operator/operation block in .pyrit_conf_example - Document known limitation in Graph overage fallback (token audience mismatch with Microsoft Graph) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Merge upstream dependency updates (pinned versions, bumps) while keeping MSAL packages, @testing-library/dom, and scheduler from this branch. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.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.
Changes
on the backend. Automatically disabled for local development.
optional private networking.
promotion.
Tests & docs
AuthProvider,msalConfig, API service).infra/README.md) and Docker quickstart (docker/QUICKSTART.md).