Detector

Trait Detector 

Source
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)
        }
    }
}

Required Methods§

Source

fn name(&self) -> &str

탐지기 이름

Source

fn detect(&self, entry: &LogEntry) -> Result<Option<Alert>, IronpostError>

로그 엔트리를 분석하여 알림 생성 여부를 결정합니다.

탐지 규칙에 매칭되면 Ok(Some(Alert))을, 매칭되지 않으면 Ok(None)을 반환합니다.

Implementors§