pub struct NegativeCache { /* private fields */ }Expand description
Negative cache for degenerate queries.
If a query signature triggers degenerate mode more than N times
in a window, forces SafetyNetBudget::DISABLED for subsequent
matches, preventing repeated budget burn on the same attack vector.
Implementations§
Source§impl NegativeCache
impl NegativeCache
Sourcepub fn new(threshold: u32, window: Duration, max_entries: usize) -> Self
pub fn new(threshold: u32, window: Duration, max_entries: usize) -> Self
Create a new negative cache.
§Arguments
threshold- Number of degenerate hits before blacklisting.window- Duration window for counting hits.max_entries- Maximum cache entries.
Sourcepub fn record_degenerate(&mut self, sig: QuerySignature) -> bool
pub fn record_degenerate(&mut self, sig: QuerySignature) -> bool
Record a degenerate query hit. Returns true if the query is
now blacklisted (should force DISABLED safety net).
Sourcepub fn is_blacklisted(&self, sig: &QuerySignature) -> bool
pub fn is_blacklisted(&self, sig: &QuerySignature) -> bool
Check if a query signature is blacklisted.
Auto Trait Implementations§
impl Freeze for NegativeCache
impl RefUnwindSafe for NegativeCache
impl Send for NegativeCache
impl Sync for NegativeCache
impl Unpin for NegativeCache
impl UnsafeUnpin for NegativeCache
impl UnwindSafe for NegativeCache
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
Mutably borrows from an owned value. Read more