Repository navigation
FEAT: Gather an Operation's selected findings in pyrit.output with build_finding_selection_async - #4836
Draft
hannahwestra25 wants to merge 2 commits into
Draft
FEAT: Gather an Operation's selected findings in pyrit.output with build_finding_selection_async#4836hannahwestra25 wants to merge 2 commits into
hannahwestra25 wants to merge 2 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>
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are recorded for the shared finding-selection and evidence-resolution changes.
No open issues 🎉
What changed in this PR
Moves finding selection and evidence resolution into pyrit.output, providing a shared builder for backend exports, notebooks, and future publishing.
Changes:
- Adds a reusable selection builder with batching, optional links, and selection limits.
- Separates evidence availability from links while preserving backend export behavior.
- Moves selection tests and documents notebook usage.
| File | Description |
|---|---|
| tests/unit/output/finding_report/test_selection.py | Tests selection, batching, limits, and evidence availability. |
| tests/unit/output/finding_report/test_report.py | Tests finding IDs, missing evidence, and report notes. |
| tests/unit/output/finding_report/test_markdown.py | Updates fixtures with explicit evidence availability. |
| tests/unit/backend/test_operations.py | Removes tests moved to the output module. |
| tests/unit/backend/test_finding_export.py | Updates export expectations and link tests. |
| pyrit/output/finding_report/selection.py | Adds shared selection and evidence resolution. |
| pyrit/output/finding_report/report.py | Adds selection data, finding IDs, and availability-aware notes. |
| pyrit/output/finding_report/markdown.py | Uses the report’s evidence note. |
| pyrit/output/__init__.py | Exposes selection APIs through lazy exports. |
| pyrit/backend/services/operation_service.py | Delegates evidence resolution to the shared resolver. |
| pyrit/backend/services/finding_export.py | Uses the selection builder with dashboard links. |
| pyrit/backend/routes/operations.py | Maps selection errors to existing HTTP responses. |
| doc/code/output/0_output.py | Documents building and printing finding reports. |
| doc/code/output/0_output.ipynb | Adds the matching notebook documentation. |
Review effort: Balanced
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
Moves the reading of a finding selection out of the backend and into
pyrit.output, so the findings export, the planned Azure DevOps findings publisher, and notebooks share one builder. This is step 2b of the publisher design, and the export's Word and Markdown output doesn't change.pyrit/output/finding_report/selection.py:build_finding_selection_asyncfollows export's existing steps in the same order. It reads the Operation, then the selected subtrees in one snapshot. It applies the optionalmax_findingscap before reading any evidence. It resolves evidence in batches of 500, projects it, and reads the titles of parents outside the selection.link_for, evidence has no links.build_finding_selection_async,FindingSelection,FindingSelectionNotFoundError,FindingSelectionTooLargeErrorandFindingEvidenceLinkTargetare exported frompyrit.output.resolve_finding_evidence_asyncandResolvedFindingEvidence, stays module-level for the backend's evidence page. It returns the domainScoreand anavailableflag.report.pychanges:FindingSelectionbundlesbuild_finding_report's inputs.build_finding_reportkeeps its signature and treats a finding without evidence as having none.FindingReportEntry.finding_idis added now for the publish planner in the next PR.FindingReportEvidencehas a requiredavailableflag, so evidence without a link isn't shown as unavailable._conversation_link, aslink_for.FindingSelectionNotFoundErrorto 404. ForFindingSelectionTooLargeErrorit returns 422 with the same text as before: "Select at most 1,000 findings to download at once, counting sub-findings."ScoreView.from_domain(score, is_objective_score=True), so the page doesn't change.OperationServicemethods that only export and their own tests called:get_finding_subtrees_async,get_finding_titles_async,get_findings_with_evidence_async, andget_evidence_for_findings_async. Also removes their private resolver helpers andFindingExportTooLargeError. Their tests, including the batching test, move totests/unit/output/finding_report/test_selection.py.doc/code/output/0_output.pyand its.ipynb). It shows how to build a report from a selection in a notebook.🤖 Generated with Claude Code