pub trait Detector: Send + Sync {
// Required methods
fn name(&self) -> &str;
fn detect(&self, entry: &LogEntry) -> Result<Option<Alert>, IronpostError>;
}Expand description
탐지 로직을 구현하는 trait
새로운 탐지 규칙을 추가하려면 이 trait을 구현합니다.
ironpost-daemon에서 빌더 패턴으로 등록하여 사용합니다.
§구현 예시
ⓘ
struct BruteForceDetector;
impl Detector for BruteForceDetector {
fn name(&self) -> &str { "brute_force" }
fn detect(&self, entry: &LogEntry) -> Result<Option<Alert>, IronpostError> {
if entry.message.contains("Failed password") {
Ok(Some(Alert { /* ... */ }))
} else {
Ok(None)
}
}
}