1pub mod builtin;
2pub mod finding;
3pub mod policy;
4
5use crate::ir::ScanTarget;
6
7pub use finding::{AttackCategory, Confidence, Evidence, Finding, RuleMetadata, Severity};
8
9pub trait Detector: Send + Sync {
11 fn metadata(&self) -> RuleMetadata;
13
14 fn run(&self, target: &ScanTarget) -> Vec<Finding>;
16}
17
18pub struct RuleEngine {
20 detectors: Vec<Box<dyn Detector>>,
21}
22
23impl RuleEngine {
24 pub fn new() -> Self {
26 Self {
27 detectors: builtin::all_detectors(),
28 }
29 }
30
31 pub fn run(&self, target: &ScanTarget) -> Vec<Finding> {
33 self.detectors.iter().flat_map(|d| d.run(target)).collect()
34 }
35
36 pub fn list_rules(&self) -> Vec<RuleMetadata> {
38 self.detectors.iter().map(|d| d.metadata()).collect()
39 }
40}
41
42impl Default for RuleEngine {
43 fn default() -> Self {
44 Self::new()
45 }
46}