#[non_exhaustive]pub struct RespLimits {
pub max_nesting_depth: usize,
pub max_bulk_length: usize,
pub max_collection_length: usize,
}Expand description
Limits the RESP parser enforces against hostile or corrupt server input.
These bound pathology, they do not police normal use: every default is generous enough for any legitimate reply, and is the value that was hardcoded before these became configurable. Raising one widens the resources a single reply can command; lowering one can reject replies a real server sends.
A frame breaching any limit fails the connection with the matching
ClientError rather than being reported as a truncated
read, so the streaming decoder never waits for bytes that will never come.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.max_nesting_depth: usizeMaximum collection-nesting depth accepted before a frame is rejected with
MaxNestingDepthExceeded.
RESP replies are shallow in practice — a handful of levels for the
deepest cluster and stream introspection commands — so this stops a
crafted *1\r\n*1\r\n… reply from driving the parser into a stack
overflow, which unlike a panic is not catchable and aborts the whole
process. The element loop is iterative, so this bounds the parser’s
explicit stack (and the recursion left in attribute skipping) rather than
the call stack.
The default is 128.
max_bulk_length: usizeMaximum byte length accepted for a single bulk string, bulk error or
verbatim string, checked against the declared header before the payload
is trusted; breaching it raises
BulkLengthTooLarge.
Matches Redis’s own proto-max-bulk-len default. Raise it only if the
server’s is also raised.
The default is 512 MiB.
max_collection_length: usizeMaximum number of elements accepted in a single collection — array, set,
push or map, counted after the map key/value doubling; breaching it raises
CollectionLengthTooLarge.
Bounds an attacker-controlled loop count and the buffer pre-reservation derived from it.
The default is 128 Mi elements.
Implementations§
Source§impl RespLimits
impl RespLimits
Trait Implementations§
Source§impl Clone for RespLimits
impl Clone for RespLimits
impl Copy for RespLimits
Source§impl Debug for RespLimits
impl Debug for RespLimits
Source§impl Default for RespLimits
impl Default for RespLimits
Source§impl<'de> Deserialize<'de> for RespLimitswhere
RespLimits: Default,
impl<'de> Deserialize<'de> for RespLimitswhere
RespLimits: Default,
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for RespLimits
Source§impl PartialEq for RespLimits
impl PartialEq for RespLimits
Source§impl Serialize for RespLimits
impl Serialize for RespLimits
impl StructuralPartialEq for RespLimits
Auto Trait Implementations§
impl Freeze for RespLimits
impl RefUnwindSafe for RespLimits
impl Send for RespLimits
impl Sync for RespLimits
impl Unpin for RespLimits
impl UnsafeUnpin for RespLimits
impl UnwindSafe for RespLimits
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.