synapse_pingora/correlation/detectors/
mod.rs1use crate::correlation::{CampaignUpdate, FingerprintIndex};
7use std::net::IpAddr;
8
9pub type DetectorResult<T> = Result<T, DetectorError>;
11
12#[derive(Debug, Clone)]
14pub enum DetectorError {
15 IndexUnavailable(String),
17 DetectionFailed(String),
19 RateLimited,
21}
22
23impl std::fmt::Display for DetectorError {
24 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
25 match self {
26 DetectorError::IndexUnavailable(msg) => write!(f, "Index unavailable: {}", msg),
27 DetectorError::DetectionFailed(msg) => write!(f, "Detection failed: {}", msg),
28 DetectorError::RateLimited => write!(f, "Detection rate limited"),
29 }
30 }
31}
32
33impl std::error::Error for DetectorError {}
34
35pub trait Detector: Send + Sync {
40 fn name(&self) -> &'static str;
42
43 fn analyze(&self, index: &FingerprintIndex) -> DetectorResult<Vec<CampaignUpdate>>;
46
47 fn should_trigger(&self, ip: &IpAddr, index: &FingerprintIndex) -> bool;
50
51 fn scan_interval_ms(&self) -> u64 {
53 5000 }
55}
56
57pub mod attack_sequence;
58pub mod auth_token;
59pub mod behavioral_similarity;
60pub mod common;
61pub mod graph;
62pub mod ja4_rotation;
63pub mod network_proximity;
64pub mod shared_fingerprint;
65pub mod timing_correlation;
66
67pub use attack_sequence::{AttackPayload, AttackSequenceConfig, AttackSequenceDetector};
68pub use auth_token::{AuthTokenConfig, AuthTokenDetector, TokenFingerprint};
69pub use behavioral_similarity::{BehaviorPattern, BehavioralConfig, BehavioralSimilarityDetector};
70pub use common::TimeWindowedIndex;
71pub use graph::{GraphConfig, GraphDetector};
72pub use ja4_rotation::{Ja4RotationDetector, Ja4RotationStats, RotationConfig};
73pub use network_proximity::{NetworkProximityConfig, NetworkProximityDetector};
74pub use shared_fingerprint::SharedFingerprintDetector;
75pub use timing_correlation::{TimingConfig, TimingCorrelationDetector};