pub struct SecurityValidator { /* private fields */ }Expand description
Security validator with configuration-based limits
Implementations§
Source§impl SecurityValidator
impl SecurityValidator
Sourcepub fn new(config: SecurityConfig) -> Self
pub fn new(config: SecurityConfig) -> Self
Create new validator with given security configuration
Sourcepub fn validate_input_size(&self, size: usize) -> Result<()>
pub fn validate_input_size(&self, size: usize) -> Result<()>
Validate input size against security limits
Sourcepub fn validate_json_depth(&self, depth: usize) -> Result<()>
pub fn validate_json_depth(&self, depth: usize) -> Result<()>
Validate JSON depth to prevent stack overflow
Sourcepub fn validate_json_depth_bytes(&self, input: &[u8]) -> Result<()>
pub fn validate_json_depth_bytes(&self, input: &[u8]) -> Result<()>
Validate JSON nesting depth by scanning raw bytes ahead of parsing.
Tracks in-string state (a " toggles it, a \ escapes the following
byte) so that {/}/[/] bytes inside string literals are never
mistaken for structural delimiters — matching the JSON grammar’s own
definition of nesting. Intended as a cheap pre-parse guard shared by
every JSON entry point, so a parser backend without its own recursion
limit (e.g. sonic-rs) cannot be driven into unbounded recursion by a
payload whose reported depth was deflated via crafted string content.
Sourcepub fn validate_array_length(&self, length: usize) -> Result<()>
pub fn validate_array_length(&self, length: usize) -> Result<()>
Validate array length
Sourcepub fn validate_object_keys(&self, key_count: usize) -> Result<()>
pub fn validate_object_keys(&self, key_count: usize) -> Result<()>
Validate object key count
Sourcepub fn validate_string_length(&self, length: usize) -> Result<()>
pub fn validate_string_length(&self, length: usize) -> Result<()>
Validate string length
Sourcepub fn validate_session_id(&self, session_id: &str) -> Result<()>
pub fn validate_session_id(&self, session_id: &str) -> Result<()>
Validate session ID format and length
Sourcepub fn validate_websocket_frame_size(&self, size: usize) -> Result<()>
pub fn validate_websocket_frame_size(&self, size: usize) -> Result<()>
Validate WebSocket frame size
Sourcepub fn validate_buffer_size(&self, size: usize) -> Result<()>
pub fn validate_buffer_size(&self, size: usize) -> Result<()>
Validate buffer size for pooling
Trait Implementations§
Source§impl Clone for SecurityValidator
impl Clone for SecurityValidator
Source§fn clone(&self) -> SecurityValidator
fn clone(&self) -> SecurityValidator
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for SecurityValidator
impl Debug for SecurityValidator
Auto Trait Implementations§
impl Freeze for SecurityValidator
impl RefUnwindSafe for SecurityValidator
impl Send for SecurityValidator
impl Sync for SecurityValidator
impl Unpin for SecurityValidator
impl UnsafeUnpin for SecurityValidator
impl UnwindSafe for SecurityValidator
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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