from __future__ import annotations import json from pathlib import Path from .model import RunReport def write_report(report: RunReport, output: str | Path) -> None: path = Path(output) path.parent.mkdir(parents=True, exist_ok=True) path.write_text(json.dumps(report.as_dict(), indent=2, sort_keys=True) + "\n", encoding="utf-8") def risk_nexus_message(report: RunReport) -> str: lines = [ f"Whitehat run `{report.run_id}`: **{report.outcome}**", "", f"- evidence class: `{report.evidence_class}`", f"- target: `{report.target}` at `{report.target_revision}`", f"- posture/model: `{report.posture_claim}` / `{report.attacker_model}`", f"- engagement/authorization: `{report.engagement_id}` / `{report.authorization_id}`", f"- attempted operations: {report.attempted_operations}", f"- interval: {report.started_at} to {report.ended_at}", "", report.assurance_statement, ] if report.outcome == "finding": lines.extend(["", "Reporter supplies facts only; risk-nexus owns severity and disclosure."]) return "\n".join(lines) + "\n"