pub struct SchemaRouter<L = LogSourceExtractor> { /* private fields */ }Expand description
A multi-engine router over a classifier, a RoutingPlan, one detection
engine per pipeline-set, and one shared correlation store.
Generic over the logsource extractor L, which defaults to
LogSourceExtractor. Build with SchemaRouter::build for the default,
or SchemaRouter::build_with_logsource_extractor for a custom
ExtractLogSource implementation.
Implementations§
Source§impl SchemaRouter
impl SchemaRouter
Sourcepub fn build(
collection: &SigmaCollection,
classifier: SchemaClassifier,
plan: RoutingPlan,
pipeline_sets: Vec<Vec<Pipeline>>,
corr_config: CorrelationConfig,
include_event: bool,
match_detail: MatchDetailLevel,
logsource_extractor: Option<LogSourceExtractor>,
partition_rules: bool,
) -> Result<Self>
pub fn build( collection: &SigmaCollection, classifier: SchemaClassifier, plan: RoutingPlan, pipeline_sets: Vec<Vec<Pipeline>>, corr_config: CorrelationConfig, include_event: bool, match_detail: MatchDetailLevel, logsource_extractor: Option<LogSourceExtractor>, partition_rules: bool, ) -> Result<Self>
Build a router. pipeline_sets must be index-aligned with
plan.pipeline_sets() (one resolved pipeline list per set).
Source§impl<L> SchemaRouter<L>
impl<L> SchemaRouter<L>
Sourcepub fn build_with_logsource_extractor(
collection: &SigmaCollection,
classifier: SchemaClassifier,
plan: RoutingPlan,
pipeline_sets: Vec<Vec<Pipeline>>,
corr_config: CorrelationConfig,
include_event: bool,
match_detail: MatchDetailLevel,
extractor: L,
partition_rules: bool,
) -> Result<Self>
pub fn build_with_logsource_extractor( collection: &SigmaCollection, classifier: SchemaClassifier, plan: RoutingPlan, pipeline_sets: Vec<Vec<Pipeline>>, corr_config: CorrelationConfig, include_event: bool, match_detail: MatchDetailLevel, extractor: L, partition_rules: bool, ) -> Result<Self>
Build a router that prunes with extractor, a custom
ExtractLogSource implementation. Arguments are otherwise as in
SchemaRouter::build. The recognized schema’s implied logsource
still fills any dimension the extractor leaves unset.
Sourcepub fn set_include_event(&mut self, include: bool)
pub fn set_include_event(&mut self, include: bool)
Set global include_event on every per-schema engine and the shared
correlation store. Takes effect for the next event evaluated.
Sourcepub fn on_unknown(&self) -> OnUnknown
pub fn on_unknown(&self) -> OnUnknown
The unknown-handling policy this router enforces.
Sourcepub fn has_correlations(&self) -> bool
pub fn has_correlations(&self) -> bool
Whether this router has a correlation store.
Sourcepub fn detection_rule_count(&self) -> usize
pub fn detection_rule_count(&self) -> usize
Number of detection rules (same across every per-schema engine, unless
per-schema rule partitioning is enabled; see engine_rule_counts).
Sourcepub fn engine_rule_counts(&self) -> Vec<usize>
pub fn engine_rule_counts(&self) -> Vec<usize>
Per-pipeline-set detection rule counts, in set order. Equal across sets unless per-schema rule partitioning is enabled, in which case platform-locked sets carry fewer rules than the default set.
Sourcepub fn logsource_pruned_total(&self) -> u64
pub fn logsource_pruned_total(&self) -> u64
Total rule candidates pruned by logsource across every per-schema engine (each event routes to exactly one engine).
Sourcepub fn logsource_absent_total(&self) -> u64
pub fn logsource_absent_total(&self) -> u64
Total evaluate calls with no extractable event logsource (fail-open) across every per-schema engine.
Sourcepub fn schema_pruning_summary(&self) -> Vec<SchemaPruning>
pub fn schema_pruning_summary(&self) -> Vec<SchemaPruning>
Static per-schema pruning summary: for each schema with an implied logsource, how many rules its events evaluate versus prune. Empty when logsource routing is disabled (no extractor). Sorted by descending pruned count, then schema name.
Sourcepub fn correlation_rule_count(&self) -> usize
pub fn correlation_rule_count(&self) -> usize
Number of correlation rules in the shared store (0 when none).
Sourcepub fn state_count(&self) -> usize
pub fn state_count(&self) -> usize
Number of live correlation window-state entries (0 when none).
Sourcepub fn rule_metadata(&self, key: &str) -> RuleMetadataLookup
pub fn rule_metadata(&self, key: &str) -> RuleMetadataLookup
Resolve a rule key (an id, or a title for a rule without one) to the documentation of every loaded rule that carries it.
A rule set is compiled once per pipeline-set, so the same rule usually
yields one candidate per schema. Candidates whose post-pipeline metadata
is identical collapse to a single answer; a rule whose pipelines rewrite
its documentation differently per schema stays
Ambiguous.
Sourcepub fn correlation_introspect(
&self,
id: Option<&str>,
group: Option<&str>,
) -> Option<CorrelationStateSnapshot>
pub fn correlation_introspect( &self, id: Option<&str>, group: Option<&str>, ) -> Option<CorrelationStateSnapshot>
Introspect the shared correlation store, if any (id/group filtered).
Sourcepub fn correlation_introspect_for_tenant(
&self,
id: Option<&str>,
group: Option<&str>,
tenant: Option<&TenantId>,
) -> Option<CorrelationStateSnapshot>
pub fn correlation_introspect_for_tenant( &self, id: Option<&str>, group: Option<&str>, tenant: Option<&TenantId>, ) -> Option<CorrelationStateSnapshot>
Like correlation_introspect, keeping
only groups owned by tenant when it is set.
Sourcepub fn export_state(&self) -> Option<CorrelationSnapshot>
pub fn export_state(&self) -> Option<CorrelationSnapshot>
Export the shared correlation state, if any, for hot-reload carry-over.
Sourcepub fn take_tenant_quota_evictions(&mut self) -> u64
pub fn take_tenant_quota_evictions(&mut self) -> u64
Entries evicted because a tenant hit its correlation quota since the previous call, draining the counter.
Sourcepub fn take_untenanted_skipped(&mut self) -> u64
pub fn take_untenanted_skipped(&mut self) -> u64
Events skipped by require_tenant since the previous call, draining the
counter.
Sourcepub fn import_state(&mut self, snapshot: CorrelationSnapshot) -> bool
pub fn import_state(&mut self, snapshot: CorrelationSnapshot) -> bool
Import previously exported correlation state into the shared store.
No-op (returns true) when there is no correlation store.
Sourcepub fn import_state_detailed(
&mut self,
snapshot: CorrelationSnapshot,
) -> Option<ImportStats>
pub fn import_state_detailed( &mut self, snapshot: CorrelationSnapshot, ) -> Option<ImportStats>
Like import_state, returning the restored and
discarded entry counts. No correlation store restores nothing.
Sourcepub fn detect_batch<E: Event + Sync>(&self, events: &[&E]) -> Vec<ProcessResult>where
L: ExtractLogSource<E> + Sync,
pub fn detect_batch<E: Event + Sync>(&self, events: &[&E]) -> Vec<ProcessResult>where
L: ExtractLogSource<E> + Sync,
Stateless classify + detection for a batch. Safe to call under a shared
borrow when there is no correlation store; see Self::process_batch.
Sourcepub fn process_batch<E: Event + Sync>(
&mut self,
events: &[&E],
) -> Vec<ProcessResult>where
L: ExtractLogSource<E> + Sync,
pub fn process_batch<E: Event + Sync>(
&mut self,
events: &[&E],
) -> Vec<ProcessResult>where
L: ExtractLogSource<E> + Sync,
Route a batch of events: parallel classify + detection, then sequential
correlation into the shared store. Mirrors
CorrelationEngine::process_batch: the stateless phase runs concurrently
(under the parallel feature) and the stateful correlation phase runs
in order. Drop/error outcomes yield empty results for that event.
When there is no correlation store this is equivalent to Self::detect_batch
and only needs a shared borrow of the router.
Sourcepub fn process_batch_for_tenants<E: Event + Sync>(
&mut self,
events: &[&E],
tenants: &[Option<TenantId>],
) -> Vec<ProcessResult>where
L: ExtractLogSource<E> + Sync,
pub fn process_batch_for_tenants<E: Event + Sync>(
&mut self,
events: &[&E],
tenants: &[Option<TenantId>],
) -> Vec<ProcessResult>where
L: ExtractLogSource<E> + Sync,
Route a batch of events with a parallel tenant slice, feeding each detection into the shared correlation store under its tenant.
tenants is empty (untenanted) or exactly parallel to events.
Sourcepub fn route<E: Event>(&mut self, event: &E) -> RouteResultwhere
L: ExtractLogSource<E>,
pub fn route<E: Event>(&mut self, event: &E) -> RouteResultwhere
L: ExtractLogSource<E>,
Classify and route one event.
Sourcepub fn route_for_tenant<E: Event>(
&mut self,
event: &E,
tenant: Option<&TenantId>,
) -> RouteResultwhere
L: ExtractLogSource<E>,
pub fn route_for_tenant<E: Event>(
&mut self,
event: &E,
tenant: Option<&TenantId>,
) -> RouteResultwhere
L: ExtractLogSource<E>,
Classify and route one event as tenant.