"""Tests for the self-contained HTML findings report renderer.""" from __future__ import annotations from typing import TYPE_CHECKING, Any from strix.report.html_report import render_html_report from strix.report.writer import write_html_report if TYPE_CHECKING: from pathlib import Path def _run_record() -> dict[str, Any]: return { "run_name": "demo_ab12", "targets_info": [{"type": "web_application", "original": "https://example.com"}], "start_time": "2026-07-22T00:00:00Z", } def _finding(**overrides: Any) -> dict[str, Any]: base: dict[str, Any] = { "id": "vuln-1", "title": "SQL Injection in login", "severity": "critical", "timestamp": "2026-07-22T00:01:00Z", "cvss": 9.8, "description": "User input concatenated into a SQL query.", "impact": "Full database read.", "poc_script_code": "' OR '1'='1", "remediation_steps": "Use parameterized queries.", "code_locations": [{"file": "app/auth.py", "start_line": 42, "snippet": "query = ..."}], } base.update(overrides) return base def test_report_is_a_full_html_document() -> None: html = render_html_report(_run_record(), [_finding()]) assert html.startswith("") assert '' in html assert "" in html # Self-contained: inline style, no external asset references. assert "