pub mod builtin;
pub mod finding;
pub mod policy;
use crate::ir::ScanTarget;
pub use finding::{AttackCategory, Confidence, Evidence, Finding, RuleMetadata, Severity};
pub trait Detector: Send + Sync {
fn metadata(&self) -> RuleMetadata;
fn run(&self, target: &ScanTarget) -> Vec<Finding>;
}
pub struct RuleEngine {
detectors: Vec<Box<dyn Detector>>,
}
impl RuleEngine {
pub fn new() -> Self {
Self {
detectors: builtin::all_detectors(),
}
}
pub fn run(&self, target: &ScanTarget) -> Vec<Finding> {
self.detectors.iter().flat_map(|d| d.run(target)).collect()
}
pub fn list_rules(&self) -> Vec<RuleMetadata> {
self.detectors.iter().map(|d| d.metadata()).collect()
}
}
impl Default for RuleEngine {
fn default() -> Self {
Self::new()
}
}