Skip to main content

custom_reportable/
custom_reportable.rs

1use secfinding::{Reportable, Severity};
2
3struct PolicyFinding {
4    source: String,
5    title: String,
6    score: f64,
7}
8
9impl Reportable for PolicyFinding {
10    fn scanner(&self) -> &str {
11        "policy-scanner"
12    }
13
14    fn target(&self) -> &str {
15        &self.source
16    }
17
18    fn severity(&self) -> Severity {
19        if self.score >= 0.9 {
20            Severity::Critical
21        } else if self.score >= 0.7 {
22            Severity::High
23        } else if self.score >= 0.5 {
24            Severity::Medium
25        } else {
26            Severity::Low
27        }
28    }
29
30    fn title(&self) -> &str {
31        &self.title
32    }
33
34    fn detail(&self) -> &str {
35        "Policy mismatch detected by governance check"
36    }
37
38    fn confidence(&self) -> Option<f64> {
39        Some(self.score)
40    }
41
42    fn tags(&self) -> Vec<String> {
43        vec!["policy".to_string(), "governance".to_string()]
44    }
45}
46
47fn main() {
48    let f = PolicyFinding {
49        source: "s3://bucket/config.yaml".into(),
50        title: "Excessive privilege policy statement".into(),
51        score: 0.93,
52    };
53
54    println!("scanner: {}", f.scanner());
55    println!("target: {}", f.target());
56    println!("severity: {}", f.severity());
57    println!("rule id: {}", f.rule_id());
58    println!("tags: {}", f.tags().join(", "));
59    println!("{}", f.detail());
60}