hyperlane-plugin-security 22.11.0

A zero-allocation security hardening plugin for the Hyperlane framework providing prebuilt HSTS/CSP/COOP/COEP/CORP/Referrer headers, stateless HMAC-SHA256 CSRF protection, host/URI/body/path-traversal guards, and extensible SecurityRule hooks.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
use super::*;

/// Extensible request inspection rule evaluated before routing.
pub trait SecurityRule: Send + Sync + 'static {
    /// Inspects `ctx` and returns `Err(SecurityViolation)` to block the request immediately.
    ///
    /// # Arguments
    ///
    /// - `&Context` - Incoming request context.
    ///
    /// # Returns
    ///
    /// - `Result<(), SecurityViolation>` - `Ok(())` to permit, or violation details to reject.
    fn inspect(&self, ctx: &Context) -> Result<(), SecurityViolation>;
}