Repository navigation
FEAT: Publish findings from CoPyRIT with a registered finding publisher - #4844
Draft
hannahwestra25 wants to merge 25 commits into
Draft
hannahwestra25 wants to merge 25 commits into
hannahwestra25 wants to merge 25 commits into
Conversation
Move reading a finding selection from the backend into pyrit/output/finding_report/selection.py, so export, the planned findings publisher, and notebooks share one builder (step 2b of the Azure DevOps findings publisher design). - build_finding_selection_async follows export's existing steps in the same order, with an optional max_findings cap and a link_for callback. resolve_finding_evidence_async returns domain types and reads evidence in batches of 500. - report.py adds FindingSelection and FindingReportEntry.finding_id. - Export passes its dashboard link builder as link_for. The export route maps FindingSelectionNotFoundError to 404 and keeps its 422 text. The evidence page maps resolved evidence with ScoreView.from_domain, so neither changes. - Remove the OperationService methods that only export used, and move their tests to the library. - Document building a report from a selection in the output guide. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A notebook report built without link_for showed intact evidence as "Evidence unavailable", because availability was derived from the link. Its opening note also promised dashboard links that the report didn't have. - FindingReportEvidence gains a required available flag, which selection sets from the resolved evidence. unavailable now reads that flag. - The opening note leaves out the dashboard clause when available evidence is listed without links. Every export links its available evidence, so export output is unchanged. - build_finding_report treats a finding without an evidence entry as having none, so a FindingSelection built from findings alone works. - Keep resolve_finding_evidence_async and ResolvedFindingEvidence module-level. Only the backend evidence page uses them. - Correct the output guide's sentence about reports without links. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…zure DevOps adapter Add a destination-neutral FindingPublisher in pyrit.output: preview_async shows where every selected finding would go, and publish_async creates the items, parents first, and reports every finding's outcome exactly once. The pure planner orders findings as the reports do, skips findings that weren't demonstrated and decides nesting; the plan digest lets a publish create only what its preview showed. Errors propagate until the first create; after that, only cancellation escapes. Add the generic, opt-in AzureDevOpsFindingPublisher: REST API 7.1 with a 30-second timeout per request, destinations parsed (never fetched) within the configured organization, JSON Patch creates with a parent link, the requester assigned, and a History note with the run and finding IDs. A 4xx or a connection that never opened is a known failure; a 5xx, a timeout after sending or an unreadable response marks the item as possibly created. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A cancelled publish logged the item whose create was in flight as not attempted, although its request may have reached the destination. The run now tracks that item and the summary reports it as "in flight 1 (outcome unknown)". Problems are now listed in plan order, as the validation error documents. Tests now fail if the History or other HTML fields go unescaped, another visualstudio.com organization is accepted, a 3xx counts as a known outcome, the project or type comparison becomes case-sensitive, a lone surrogate is allowed in a title, or a request starts with less than a full timeout left. The two real-timeout tests shorten only the hanging request's timeout. The output guide's in-memory publisher is now a runnable cell, and the guide notes that PyRIT's default severity and harm_type fields must be unmapped. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Assert the exact summary line of a run that creates every item, so a run that forgets to clear its in-flight item fails the tests. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Address review of the finding selection: - FindingSelection holds data only: operation_id, operation_name, the findings, their resolved evidence, and part_of, with no defaults. - build_finding_report(*, selection, fields, link_for=None) projects the evidence. _project_evidence and _score_text move into report.py, and link_for moves from the selection to the report. build_finding_report is exported from pyrit.output. - The report's opening note mentions dashboard links only when a link builder is given, instead of walking the entries. - ResolvedFindingEvidence moves to pyrit.models, and the resolver becomes MemoryInterface.get_resolved_finding_evidence_async, still batched by 500. The selection builder and the backend evidence page both call it, so report.py and selection.py don't import each other. - Remove FindingReportEntry.finding_id until the publish planner reads it. Export output is byte-identical to main. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Link two pieces of evidence to one finding at different times, and assert the selection and the report list them newest first. - Project a score with no scorer identifier, and one with an empty class name, through build_finding_report and expect "<value> (Unknown)". Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Turn the fenced example into a code cell that records an Operation with one finding in the guide's in-memory database, then reads, builds, and prints its report. The stored output comes from executing the cell. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
PR microsoft#4836 now keeps FindingSelection as data only, builds reports with build_finding_report(selection=..., fields=..., link_for=...), resolves evidence in memory, and no longer adds FindingReportEntry.finding_id. The only conflict, in pyrit/output/__init__.py, keeps both sides: microsoft#4836's report exports and the publisher exports. The publishers are adapted in the following commits. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
build_finding_report sets each entry's saved finding ID, so a publish plan can join a report entry to its finding. No report format shows the field, so the Word and Markdown exports don't change. microsoft#4836 dropped the field to land it with its consumer, the planner in this branch. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The planner now lays a selection out with build_finding_report, like the exports do. preview_async and publish_async take a keyword-only link_for and pass it through, so evidence in published items can link back, for example to a public dashboard route. Links stay out of the publisher's identifier and out of the plan digest: they change what an item says, not which items are created or where. The output guide, its runnable in-memory publisher and the output instructions use the new selection and link_for. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…t availability Make FindingReportEvidence.available optional. None infers availability from link_url, as in PyRIT 1.2, so evidence built by hand keeps its old behavior. build_finding_report still sets it explicitly, so intact evidence without a link is not shown as unavailable. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Nothing a preview returns depends on evidence links: the plan digest leaves them out, and the problem checks read only titles and values. So preview_async no longer takes link_for, and publish_async keeps it. The digest test now publishes with links against the digest of a preview without them, so it fails if links ever enter the digest. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
microsoft#4836 makes FindingReportEvidence.available optional, so evidence built without it infers availability from its link again. The only conflict, in tests/unit/output/finding_report/test_report.py, keeps both added tests: this branch's finding_id test and microsoft#4836's availability test. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Add FindingPublisherRegistry, which holds configured publishers by name,
catalogs no classes and is cleared by reset_setup_registries().
Add GET /api/finding-publishers and the Check and Publish routes under
/api/operations/{operation_id}/findings/publish. The service gathers the
selection with build_finding_selection_async, caps it at 100 findings
counting sub-findings, gives each request one 210-second deadline, takes
the requester from the signed-in user and links evidence to the new
PYRIT_PUBLIC_ORIGIN setting. Errors map to explicit problem responses;
the publisher's own 401 becomes a 502 so the dashboard never retries a
publish.
The operation page shows Publish findings only when a publisher is
registered. The dialog shares the export dialog's selection tree, now
FindingSelectionTree, presents what Check and Publish return, and enables
Publish only after a clean Check of the current selection and destination.
Bicep sets PYRIT_PUBLIC_ORIGIN and a 300-second termination grace period,
and the deploy pipeline waits up to 90 checks for the app to stop.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Keep a Check after a failed Publish only when the backend's problem type says nothing was created, such as an unavailable service or a passed deadline. After no response, a gateway's error or any other failure, clear it and warn that items might exist, so the same plan isn't published twice. Clear the Check whenever the selection or destination changes, instead of hiding it until the request matches again. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Selection gathering is not bounded by the admission deadline, so blocked queries or lengthy evidence resolution can exceed the 240-second ingress timeout while server work continues.
1 open issue
What changed in this PR
Connects CoPyRIT’s operation page to the finding-publishing library introduced in #4839, enabling deployments to offer publishing through registered publishers.
Changes:
- Adds publisher registration, discovery, preview, and publish APIs.
- Adds a Check-before-Publish dialog and shares finding selection with export.
- Configures public evidence links and longer shutdown grace, with supporting tests and documentation.
| File | Description |
|---|---|
| tests/unit/registry/test_finding_publisher_registry.py | Tests registration and reset behavior. |
| tests/unit/output/finding_report/test_selection.py | Tests selection and evidence gathering. |
| tests/unit/output/finding_report/test_report.py | Tests report projection and availability. |
| tests/unit/output/finding_report/test_markdown.py | Updates report rendering tests. |
| tests/unit/output/finding_publisher/test_plan.py | Tests publishing plans and digests. |
| tests/unit/memory/test_resolved_finding_evidence.py | Tests shared evidence resolution. |
| tests/unit/infra/test_code_deployment.py | Checks shutdown waits exceed grace period. |
| tests/unit/infra/test_bicep_topology.py | Checks origin and shutdown configuration. |
| tests/unit/backend/test_operations.py | Moves shared evidence tests to library coverage. |
| tests/unit/backend/test_finding_export.py | Updates export regression coverage. |
| tests/end_to_end/browser_initializer.py | Registers an offline publisher. |
| pyrit/setup/initialization.py | Resets publisher registrations. |
| pyrit/registry/components/finding_publisher_registry.py | Holds configured publisher instances. |
| pyrit/registry/components/__init__.py | Exports publisher registry types. |
| pyrit/registry/__init__.py | Exposes publisher registry APIs. |
| pyrit/output/finding_report/selection.py | Gathers selected findings and evidence. |
| pyrit/output/finding_report/report.py | Builds reports from shared selections. |
| pyrit/output/finding_report/markdown.py | Uses report-specific evidence notes. |
| pyrit/output/finding_publisher/plan.py | Plans publishing order, nesting, and digests. |
| pyrit/output/finding_publisher/errors.py | Defines publishing errors. |
| pyrit/output/finding_publisher/__init__.py | Introduces the publisher package. |
| pyrit/output/__init__.py | Exposes reporting and publishing APIs. |
| pyrit/models/resolved_finding_evidence.py | Defines resolved evidence data. |
| pyrit/models/finding_publication.py | Defines publishing contracts. |
| pyrit/models/__init__.py | Exports publication and evidence models. |
| pyrit/memory/memory_interface.py | Centralizes batched evidence resolution. |
| pyrit/backend/services/operation_service.py | Reuses shared evidence resolution. |
| pyrit/backend/services/finding_publish.py | Coordinates registered publishers and selections. |
| pyrit/backend/services/finding_export.py | Reuses library selection and reporting. |
| pyrit/backend/routes/operations.py | Adds preview, publish, and error responses. |
| pyrit/backend/routes/finding_publishers.py | Lists registered publishers. |
| pyrit/backend/routes/common.py | Extracts the signed-in requester. |
| pyrit/backend/README.md | Documents publishing APIs and configuration. |
| pyrit/backend/models/operations.py | Extracts shared selection and origin validation. |
| pyrit/backend/models/finding_publishers.py | Defines publisher API requests and listings. |
| pyrit/backend/main.py | Registers publisher routes. |
| infra/README.md | Documents public origin and shutdown behavior. |
| infra/pipelines/deploy_app.sh | Extends shutdown polling. |
| infra/application.bicep | Sets public origin and termination grace. |
| frontend/src/utils/findingTree.ts | Shares tree-selection calculations. |
| frontend/src/types/index.ts | Adds publishing API types. |
| frontend/src/services/api.ts | Adds publisher and publishing requests. |
| frontend/src/hooks/useFindingPublishers.ts | Loads registered publishers. |
| frontend/src/hooks/useFindingPublish.ts | Manages checks and publishing outcomes. |
| frontend/src/hooks/useAllOperationFindings.ts | Shares paginated finding loading. |
| frontend/src/components/Operations/OperationDetailPage.tsx | Offers publishing when configured. |
| frontend/src/components/Operations/OperationDetailPage.test.tsx | Tests conditional publishing availability. |
| frontend/src/components/Operations/FindingSelectionTree.tsx | Adds reusable hierarchical selection. |
| frontend/src/components/Operations/FindingSelectionTree.test.tsx | Tests selection behavior and accessibility. |
| frontend/src/components/Operations/FindingSelectionTree.styles.ts | Shares selection-tree styling. |
| frontend/src/components/Operations/FindingPublishDialog.tsx | Adds preview and publish interaction. |
| frontend/src/components/Operations/FindingPublishDialog.styles.ts | Styles the publishing dialog. |
| frontend/src/components/Operations/findingPublish.contract.json | Supplies example publishing responses. |
| frontend/src/components/Operations/FindingExportDialog.tsx | Reuses shared loading and selection. |
| frontend/src/components/Operations/FindingExportDialog.styles.ts | Removes extracted tree styles. |
| frontend/playwright.config.ts | Sets the browser-test public origin. |
| frontend/e2e/operations.spec.ts | Exercises Check and Publish end to end. |
| doc/gui/0_gui.md | Explains the publishing workflow. |
| doc/code/output/0_output.py | Adds reporting and publishing examples. |
| doc/code/output/0_output.ipynb | Adds corresponding notebook examples. |
| .github/instructions/output.instructions.md | Documents publisher responsibilities and constraints. |
Review effort: Balanced
Comment on lines
+138
to
+140
| return await build_finding_selection_async( | ||
| operation_id=operation_id, finding_ids=request.finding_ids, fields=fields, max_findings=MAX_PUBLISH_FINDINGS | ||
| ) |
Read and validate PYRIT_PUBLIC_ORIGIN once, when the runtime applies its configuration after loading the environment files, so a Reinitialize reads it again. The routes take the stored origin and still return 503 /errors/public-origin without one; a value that isn't an origin is logged at startup. Log one WARNING with the error class and its diagnostics when opening the destination fails with a 400 or 502, without names, emails or field values. Pin the problem types a Check or Publish can return in the contract fixture, test each route error's type, and test that the publish route passes the signed-in user as the requester. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Show "Could not load finding publishers" with Retry on the operation page when the list can't be read, instead of silently hiding Publish findings; the button is hidden only when the list loads empty. Take the problem types that mean nothing was created from the contract fixture the backend tests, so a 422 for too many findings or an invalid request clears the Check without warning that items might exist. In the dialog, press Enter in the destination to run Check, never Publish; line Check up with the input; announce a finished Check through an always-present live region; replace the re-publish warning with "Fix N problems, then check again." when the Check finds problems; and mark an unknown outcome without repeating the publisher's advice. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Cover changing the selection and changing it back, and a reload for changed finding fields that lists different findings. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The base recorded a created item after the guarded call to _create_item_async. If a publisher returned something other than a FindingPublishedItem, the exception escaped after the item may already have existed, which broke the rule that only cancellation escapes after the first create. The run now checks and records the returned item inside the guard. An invalid result becomes the run's failure with an unknown outcome, the rest are not attempted, and the summary still logs. Recording reads the item before changing the run, so a bad value can't leave it half updated. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ty doesn't read mypy-style error codes in type-ignore comments, so the fake publisher's deliberately invalid return value now uses cast. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Give publisher configuration errors their own problem type, /errors/publisher-misconfigured, still a 500, and classify it as nothing created. The catch-all /errors/internal-error and /errors/bad-request stay unclassified: an unexpected error could follow a create, so the dialog clears the Check and warns that items might exist. The contract test now requires the classified types to be exactly the routes' mapped problems plus FastAPI's validation error. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…s input Leave the destination input enabled while a Check runs, so Enter, which starts the Check, never moves focus to the page behind the modal; typing still drops the running Check. Put the hint back in the field, directly under the input at every width, and line Check up with the input in a grid that stacks Check below on narrow screens. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
None, a string and a dict all fail when the run reads external_id, so the type check on a create's result went untested. A look-alike object with external_id now has to be reported as a possibly-created failure too. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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
Adds Publish findings to the operation page, so operators can send selected findings to another system, such as Azure DevOps, through the library's
FindingPublisher. This is step 3 of the publishing design. Stacked on #4839; its commits appear until it merges. It depends on step 0:atml's owners choosing the publishing identity and its grant, and the maintainers agreeing that Output covers publishing. Until a deployment registers a publisher, nothing changes for users.FindingPublisherRegistryholds configured publishers by name. It catalogs no classes, andreset_setup_registries()clears it.GET /api/finding-publishers, a Check atPOST .../findings/publish/preview, andPOST .../findings/publish, which must send the Check'splan_digest. Each request takes at most 100 findings and 210 seconds, and publishes for the signed-in user. The publisher's 401 becomes a 502, so the dashboard never retries a publish.FindingSelectionTree, and shows what the server returned. Publish needs a clean Check of the current selection and destination.PYRIT_PUBLIC_ORIGIN, which evidence links open, and a 300-second termination grace period. The pipeline now waits up to 90 checks for the app to stop.Screenshots (offline test publisher; no Azure DevOps calls)
🤖 Generated with Claude Code