Skip to main content

SecurityMonitor

Trait SecurityMonitor 

Source
pub trait SecurityMonitor: Send + Sync {
    // Required methods
    fn on_decryption_failure(&self, ctx: &FailureContext);
    fn on_anomalous_access(&self, ctx: &AccessContext);
    fn on_threshold_breach(&self, ctx: &ThresholdContext);
}
Expand description

Outbound channel for anomaly events.

Implementations should treat monitor calls as advisory and fire-and-forget: the vault must not block on a monitor, must not crash if a monitor panics or returns an error, and must not retry. Implementations that need retry, queuing, or batching are expected to handle that internally (typically on a background thread).

§Implementor contract

  • Non-blocking. Calls must return promptly. Network or disk work should be deferred to a background worker.
  • No panics. A panicking monitor implementation is a bug in the implementation, not the vault. Wrap fallible operations and absorb their errors.
  • No key material in calls. None of the context structs carry raw key bytes; do not introduce custom side-channels that do.
  • Send + Sync. Monitors are shared across threads.

Required Methods§

Source

fn on_decryption_failure(&self, ctx: &FailureContext)

Called when a decryption attempt fails.

Source

fn on_anomalous_access(&self, ctx: &AccessContext)

Called when an access pattern looks anomalous to the configured detector.

Source

fn on_threshold_breach(&self, ctx: &ThresholdContext)

Called when a configured failure threshold is crossed.

Implementors§