use super::html_escape; use compliance_core::models::dast::DastFinding; pub(super) fn executive_summary( findings: &[DastFinding], target_name: &str, target_url: &str, tool_count: usize, tool_invocations: u32, success_rate: f64, ) -> String { let critical = findings .iter() .filter(|f| f.severity.to_string() == "critical") .count(); let high = findings .iter() .filter(|f| f.severity.to_string() == "high") .count(); let medium = findings .iter() .filter(|f| f.severity.to_string() == "medium") .count(); let low = findings .iter() .filter(|f| f.severity.to_string() == "low") .count(); let info = findings .iter() .filter(|f| f.severity.to_string() == "info") .count(); let exploitable = findings.iter().filter(|f| f.exploitable).count(); let total = findings.len(); let overall_risk = if critical > 0 { "CRITICAL" } else if high > 0 { "HIGH" } else if medium > 0 { "MEDIUM" } else if low > 0 { "LOW" } else { "INFORMATIONAL" }; let risk_color = match overall_risk { "CRITICAL" => "#991b1b", "HIGH" => "#c2410c", "MEDIUM" => "#a16207", "LOW" => "#1d4ed8", _ => "#4b5563", }; let risk_score: usize = std::cmp::min(100, critical * 25 + high * 15 + medium * 8 + low * 3 + info); let severity_bar = build_severity_bar(critical, high, medium, low, info, total); // Table of contents finding sub-entries let severity_order = ["critical", "high", "medium", "low", "info"]; let toc_findings_sub = if !findings.is_empty() { let mut sub = String::new(); let mut fnum = 0usize; for &sev_key in severity_order.iter() { let count = findings .iter() .filter(|f| f.severity.to_string() == sev_key) .count(); if count == 0 { continue; } for f in findings .iter() .filter(|f| f.severity.to_string() == sev_key) { fnum += 1; sub.push_str(&format!( r#"
This report presents the results of an automated penetration test conducted against
{target_name} ({target_url}) using the Compliance Scanner
AI-powered testing engine. A total of {total_findings} vulnerabilities were
identified, of which {exploitable_count} were confirmed exploitable with
working proof-of-concept payloads. The assessment employed {tool_count} security tools
across {tool_invocations} invocations ({success_rate:.0}% success rate).