feat(evidence): the evidence pack of a target, served as a ZIP (#285) #352

Merged
sharang merged 1 commits from feat/evidence-zip into main 2026-09-23 15:37:46 +00:00
Owner

Closes #285 (re-scoped for the pilot). Pilot P2, item K.

Scope

Per the pilot decision, the evidence is served on request through the API and MCP, and breakpilot's document service writes the reports. So compared with the issue text: no report.pdf and no report.html (Prüfwerk renders no PDF), no monthly job, and no stored packs. The audit event waits for MVP-1.6; a usage event is emitted.

What

GET /api/v1/targets/{id}/evidence-pack returns a ZIP:

File Content
oscal-assessment-results.json CRA Annex I assessment from the findings' control refs
sbom.cdx.json, sbom.spdx.json the SBOM in CycloneDX 1.5 and SPDX 2.3
findings.json, findings.csv every finding; CSV cells quoted, and a leading = + - @ defused against spreadsheet formulas
cve-alerts.json the target's CVE alerts
manifest.json each file's sha256 and size; the target; the last scan run (status, times, skipped stages); the image's tool versions (/opt/pruefwerk/tool-versions.json); the sha256 of the CRA control map that produced the mapping
  • The pack is built with spawn_blocking. It returns 404 for an unknown target and 413 past 50,000 findings or the SBOM export limit.
  • The SBOM export now uses the same builders (evidence::sbom_docs) and produces the same documents as before.
  • Dashboard: "Nachweispaket herunterladen" on each target's details, streamed through the dashboard server (FileStream::from_raw) instead of held in memory. agent_client::ok_response handles refusals.

Verification

  • Unit tests:
    • the ZIP holds every file and each manifest hash matches its file;
    • CSV quoting and formula defusing;
    • both SBOM formats.
  • Integration test (MongoDB), tests/evidence.rs: a target with a pentest finding → 200 application/zip; the manifest names the target, the OSCAL has cra-ai-8, and the CSV has the location. An unknown target → 404.
  • clippy with the CI flags (agent, dashboard server/web); fmt; tests.
  • The streamed download has not been clicked in a browser yet.

First of four stacked P2 PRs: #352 (this) → #353 MCP tools → #354 CRA status → #355 retention.

🤖 Generated with Claude Code

https://claude.ai/code/session_01EYKjxacrr6K88DruUmP48p

Closes #285 (re-scoped for the pilot). Pilot P2, item K. ## Scope Per the pilot decision, the evidence is **served on request** through the API and MCP, and breakpilot's document service writes the reports. So compared with the issue text: **no `report.pdf` and no `report.html`** (Prüfwerk renders no PDF), **no monthly job**, and no stored packs. The audit event waits for MVP-1.6; a usage event is emitted. ## What `GET /api/v1/targets/{id}/evidence-pack` returns a ZIP: | File | Content | |---|---| | `oscal-assessment-results.json` | CRA Annex I assessment from the findings' control refs | | `sbom.cdx.json`, `sbom.spdx.json` | the SBOM in CycloneDX 1.5 and SPDX 2.3 | | `findings.json`, `findings.csv` | every finding; CSV cells quoted, and a leading `= + - @` defused against spreadsheet formulas | | `cve-alerts.json` | the target's CVE alerts | | `manifest.json` | each file's sha256 and size; the target; the last scan run (status, times, skipped stages); the image's tool versions (`/opt/pruefwerk/tool-versions.json`); the **sha256 of the CRA control map** that produced the mapping | - The pack is built with `spawn_blocking`. It returns 404 for an unknown target and 413 past 50,000 findings or the SBOM export limit. - The SBOM export now uses the same builders (`evidence::sbom_docs`) and produces the same documents as before. - Dashboard: **"Nachweispaket herunterladen"** on each target's details, streamed through the dashboard server (`FileStream::from_raw`) instead of held in memory. `agent_client::ok_response` handles refusals. ## Verification - Unit tests: - the ZIP holds every file and each manifest hash matches its file; - CSV quoting and formula defusing; - both SBOM formats. - Integration test (MongoDB), `tests/evidence.rs`: a target with a pentest finding → 200 `application/zip`; the manifest names the target, the OSCAL has `cra-ai-8`, and the CSV has the location. An unknown target → 404. - clippy with the CI flags (agent, dashboard `server`/`web`); fmt; tests. - The streamed download has not been clicked in a browser yet. First of four stacked P2 PRs: #352 (this) → #353 MCP tools → #354 CRA status → #355 retention. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01EYKjxacrr6K88DruUmP48p
sharang added 1 commit 2026-09-23 15:15:05 +00:00
feat(evidence): the evidence pack of a target, served as a ZIP (#285)
CI / Check (push) Skipped
CI / Detect Changes (pull_request) Skipped
CI / Deploy Agent (pull_request) Skipped
CI / Deploy Dashboard (pull_request) Skipped
CI / Deploy Docs (pull_request) Skipped
CI / Deploy MCP (pull_request) Skipped
CI / Check (pull_request) Successful in 6m19s
a5fe0da147
The pilot's evidence is served on request and pulled by breakpilot's
document service, which writes the reports; Prüfwerk renders no PDF.

GET /api/v1/targets/{id}/evidence-pack returns a ZIP with:
- oscal-assessment-results.json (CRA Annex I, from the findings' refs)
- sbom.cdx.json and sbom.spdx.json
- findings.json and findings.csv (formula-safe cells)
- cve-alerts.json
- manifest.json: each file's sha256 and size, the target, the last scan
  run (status, times, skipped stages), the image's tool versions and the
  sha256 of the CRA control map that produced the mapping.

404 for an unknown target, 413 past 50,000 findings or the SBOM export
limit; built off the async runtime; each pack is a usage event.

The SBOM export now uses the same document builders (evidence::sbom_docs)
and produces the same documents as before.

Dashboard: "Nachweispaket herunterladen" on each target's details, streamed
through the dashboard server (FileStream) rather than held in memory.

Tests: the pack holds every file and the manifest hashes match; CSV
quoting and formula defusing; both SBOM formats; an integration test
(MongoDB) of a target with a pentest finding and an unknown target.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EYKjxacrr6K88DruUmP48p
sharang merged commit c62b5c7ee2 into main 2026-09-23 15:37:46 +00:00
Sign in to join this conversation.