Skip to main content

RitaBeaconDetector

Struct RitaBeaconDetector 

Source
pub struct RitaBeaconDetector<K>
where K: Hash + Eq + Clone,
{ /* private fields */ }
Expand description

Per-key RITA-style robust beacon detector.

Implementations§

Source§

impl<K> RitaBeaconDetector<K>
where K: Hash + Eq + Clone,

Source

pub fn new() -> Self

Default tuning: window=20, interval ∈ [10 s, 24 h], duration bonus saturates at 30 min — RITA’s standard thresholds, matching BeaconDetector.

Source

pub fn with_window(self, window: usize) -> Self

Source

pub fn with_interval_range(self, min: Duration, max: Duration) -> Self

Source

pub fn with_anomaly_threshold(self, threshold: f64) -> Self

Composite-score floor for Self::observe_gated emission (default 0.7). Issue #131.

Source

pub fn with_cooldown(self, cooldown: Duration) -> Self

Per-key re-emission cooldown for Self::observe_gated (default 300 s). Issue #131.

Source

pub fn observe( &mut self, key: K, ts: Timestamp, bytes: u64, ) -> Option<RitaBeaconScore<K>>

Record one observation for key. Returns Some once the window holds ≥ 10 samples and the mean interval is in range.

Source

pub fn forget(&mut self, key: &K)

Drop per-key state (call on flow end).

Source

pub fn observe_gated( &mut self, key: K, ts: Timestamp, bytes: u64, ) -> Option<RitaBeaconScore<K>>

Self::observe plus the emission policy: Some only at or above the anomaly threshold with the per-key cooldown elapsed. The gate the Detector registry impl uses (issue #131).

Source

pub fn evict_stale(&mut self, now: Timestamp, ttl: Duration)

Drop keys whose newest sample is older than ttl before now — bounds memory across key churn (issue #131).

Source

pub fn tracked(&self) -> usize

Number of keys currently tracked.

Trait Implementations§

Source§

impl<K> Default for RitaBeaconDetector<K>
where K: Hash + Eq + Clone,

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<K: KeyFields + Send> Detector<K> for RitaBeaconDetector<HostPair>

Available on crate feature tracker only.
Source§

fn on_flow_end( &mut self, key: &K, stats: &FlowStats, _history: &HistoryString, _l4: Option<L4Proto>, ts: Timestamp, out: &mut Vec<OwnedAnomaly>, )

Same feed as the CV impl — see BeaconDetector’s on_flow_end docs.

Source§

fn kind(&self) -> DetectorKind

Typed identity — lands on every anomaly this detector emits and drives metric labels / ATT&CK tagging.
Source§

fn tracked(&self) -> usize

Keys currently tracked (0 for stateless detectors).
Source§

fn evict_expired(&mut self, now: Timestamp)

Drop per-key state stale relative to now — bounds memory across key churn.
Source§

fn on_flow_start( &mut self, _key: &K, _ts: Timestamp, _out: &mut Vec<OwnedAnomaly>, )

New flow observed (FlowEvent::Started).
Source§

fn on_flow_established( &mut self, _key: &K, _ts: Timestamp, _out: &mut Vec<OwnedAnomaly>, )

TCP 3-way handshake completed (FlowEvent::Established).
Source§

fn on_flow_tick( &mut self, _key: &K, _stats: &FlowStats, _ts: Timestamp, _out: &mut Vec<OwnedAnomaly>, )

Periodic live-flow snapshot (FlowEvent::Tick — only fires when FlowTrackerConfig::flow_tick_interval is set). Note tick stats are cumulative; delta-track inside the detector if you need per-interval values.
Source§

fn on_dns_query( &mut self, _key: &K, _qname: &str, _ts: Timestamp, _out: &mut Vec<OwnedAnomaly>, )

DNS query name observed on flow key. Pre-extracted &str (e.g. from a DnsMessage::Query’s first question) — feed it via DetectorRegistry::observe_dns from your DNS slot drain, resolver log, or any other name source.

Auto Trait Implementations§

§

impl<K> Freeze for RitaBeaconDetector<K>
where HashMap<K, RitaState>: Freeze,

§

impl<K> RefUnwindSafe for RitaBeaconDetector<K>
where HashMap<K, RitaState>: RefUnwindSafe,

§

impl<K> Send for RitaBeaconDetector<K>
where HashMap<K, RitaState>: Send,

§

impl<K> Sync for RitaBeaconDetector<K>
where HashMap<K, RitaState>: Sync,

§

impl<K> Unpin for RitaBeaconDetector<K>
where HashMap<K, RitaState>: Unpin,

§

impl<K> UnsafeUnpin for RitaBeaconDetector<K>
where HashMap<K, RitaState>: UnsafeUnpin,

§

impl<K> UnwindSafe for RitaBeaconDetector<K>
where HashMap<K, RitaState>: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

Source§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

Source§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

Source§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more