pub struct Engine { /* private fields */ }Expand description
Main WAF rule engine.
Implementations§
Source§impl Engine
impl Engine
Sourcepub fn set_max_risk(&self, max_risk: f64)
pub fn set_max_risk(&self, max_risk: f64)
Set maximum risk score (100.0 default, 1000.0 for extended range).
Sourcepub fn set_repeat_multipliers(&self, enabled: bool)
pub fn set_repeat_multipliers(&self, enabled: bool)
Enable or disable repeat offender multipliers.
Sourcepub fn load_rules(&mut self, json: &[u8]) -> Result<usize, WafError>
pub fn load_rules(&mut self, json: &[u8]) -> Result<usize, WafError>
Load rules from JSON bytes.
Sourcepub fn precompute_rules(&self, json: &[u8]) -> Result<CompiledRules, WafError>
pub fn precompute_rules(&self, json: &[u8]) -> Result<CompiledRules, WafError>
Precompute all rule structures including regex compilation.
This is an expensive operation that should happen outside of global locks.
Sourcepub fn reload_from_compiled(&mut self, compiled: CompiledRules)
pub fn reload_from_compiled(&mut self, compiled: CompiledRules)
Fast swap of rule state using precomputed data.
Sourcepub fn parse_rules(json: &[u8]) -> Result<Vec<WafRule>, WafError>
pub fn parse_rules(json: &[u8]) -> Result<Vec<WafRule>, WafError>
Parse rules from JSON bytes without modifying engine state.
Sourcepub fn reload_rules(&mut self, rules: Vec<WafRule>) -> Result<(), WafError>
pub fn reload_rules(&mut self, rules: Vec<WafRule>) -> Result<(), WafError>
Reload the engine with a new set of rules.
Sourcepub fn rule_count(&self) -> usize
pub fn rule_count(&self) -> usize
Get the number of loaded rules.
Sourcepub fn analyze_with_trace(
&self,
req: &Request<'_>,
trace: &mut dyn TraceSink,
) -> Verdict
pub fn analyze_with_trace( &self, req: &Request<'_>, trace: &mut dyn TraceSink, ) -> Verdict
Analyze a request and emit evaluation trace events.
Sourcepub fn analyze_with_timeout(
&self,
req: &Request<'_>,
timeout: Duration,
) -> Verdict
pub fn analyze_with_timeout( &self, req: &Request<'_>, timeout: Duration, ) -> Verdict
Analyze a request with a timeout to prevent DoS via complex regexes.
§Arguments
req- The request to analyzetimeout- Maximum time allowed for rule evaluation (capped at MAX_EVAL_TIMEOUT)
§Returns
A Verdict with timed_out=true if evaluation exceeded the deadline.
Partial results (rules evaluated before timeout) are still included.
Sourcepub fn analyze_safe(&self, req: &Request<'_>) -> Verdict
pub fn analyze_safe(&self, req: &Request<'_>) -> Verdict
Analyze a request with the default timeout (DEFAULT_EVAL_TIMEOUT).
Auto Trait Implementations§
impl !Freeze for Engine
impl !RefUnwindSafe for Engine
impl Send for Engine
impl Sync for Engine
impl Unpin for Engine
impl UnsafeUnpin for Engine
impl UnwindSafe for Engine
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more