Skip to main content

sentri_report/
report.rs

1//! Report data structures.
2
3use serde::{Deserialize, Serialize};
4
5/// A complete analysis report.
6#[derive(Debug, Clone, Serialize, Deserialize)]
7pub struct Report {
8    /// Report title.
9    pub title: String,
10
11    /// Timestamp of generation.
12    pub generated_at: String,
13
14    /// Program analyzed.
15    pub program: String,
16
17    /// Total invariants checked.
18    pub invariants_checked: usize,
19
20    /// Violations found.
21    pub violations_found: usize,
22
23    /// Coverage percentage.
24    pub coverage_percent: u8,
25
26    /// Functions protected.
27    pub protected_functions: Vec<String>,
28
29    /// Functions not protected.
30    pub unprotected_functions: Vec<String>,
31
32    /// Severity breakdown.
33    pub severity_breakdown: SeverityBreakdown,
34}
35
36/// Breakdown by severity.
37#[derive(Debug, Clone, Default, Serialize, Deserialize)]
38pub struct SeverityBreakdown {
39    /// Critical violations.
40    pub critical: usize,
41    /// High severity violations.
42    pub high: usize,
43    /// Medium severity violations.
44    pub medium: usize,
45    /// Low severity violations.
46    pub low: usize,
47}
48
49impl Report {
50    /// Create a new report.
51    pub fn new(title: String, program: String) -> Self {
52        Self {
53            title,
54            generated_at: chrono::Utc::now().to_rfc3339(),
55            program,
56            invariants_checked: 0,
57            violations_found: 0,
58            coverage_percent: 0,
59            protected_functions: Vec::new(),
60            unprotected_functions: Vec::new(),
61            severity_breakdown: SeverityBreakdown::default(),
62        }
63    }
64}