pub struct ScannerConfig {
pub unicode_detection: bool,
pub injection_detection: bool,
pub path_traversal_detection: bool,
pub xss_detection: Option<bool>,
pub crypto_detection: bool,
pub enhanced_mode: Option<bool>,
pub custom_patterns: Option<PathBuf>,
pub max_scan_depth: usize,
pub enable_event_buffer: bool,
pub max_content_size: usize,
pub max_input_size: Option<usize>,
}Expand description
Scanner configuration for threat detection settings
§Security Implications
The scanner is your first line of defense against malicious input:
- Disabling any detection reduces security coverage
- Custom patterns can detect organization-specific threats
- Scan depth limits prevent algorithmic complexity attacks
- Enhanced mode provides better detection at a performance cost
§Example: Secure Production Configuration
[scanner]
unicode_detection = true # Detect unicode attacks
injection_detection = true # Detect SQL/command injection
path_traversal_detection = true # Detect directory traversal
xss_detection = true # Detect XSS attempts
enhanced_mode = true # Maximum security (if available)
max_scan_depth = 20 # Deep scanning for nested payloads
custom_patterns = "/etc/kindly-guard/patterns.toml"Fields§
§unicode_detection: boolEnable unicode threat detection
Default: true (secure by default) Security: Detects BiDi overrides, zero-width chars, homoglyphs. Essential for preventing unicode-based attacks and spoofing. Warning: Disabling exposes you to text direction manipulation
injection_detection: boolEnable injection detection
Default: true (secure by default) Security: Detects SQL, NoSQL, command, and LDAP injection attempts. Critical for preventing code execution and data breaches. Coverage: SQL, shell commands, LDAP queries, NoSQL operations
path_traversal_detection: boolEnable path traversal detection
Default: true (secure by default) Security: Detects attempts to access files outside intended directories. Prevents unauthorized file access and directory listing. Patterns: ../, .., absolute paths, URL encoding variants
xss_detection: Option<bool>Enable XSS detection
Default: Some(true) (secure by default) Security: Detects cross-site scripting attempts in various contexts. Essential for web-facing applications and APIs. Coverage: Script tags, event handlers, data URIs, SVG attacks
crypto_detection: boolEnable cryptographic security detection
Default: true (secure by default) Security: Detects weak cryptographic patterns and insecure implementations. Critical for preventing cryptographic vulnerabilities and data exposure. Coverage: Deprecated algorithms (MD5, SHA1, DES), weak keys, insecure RNG, bad KDF 2025 Standards: Enforces current NIST recommendations for key sizes and algorithms
enhanced_mode: Option<bool>Enable enhanced mode for scanners (uses advanced algorithms when available)
Default: Some(false) (standard mode) Security: Enhanced mode provides deeper analysis and pattern correlation. Better detection accuracy at the cost of some performance. Trade-off: 10-20% performance impact for 50%+ better detection
custom_patterns: Option<PathBuf>Custom threat patterns file
Default: None
Security: Add organization-specific threat patterns.
Useful for detecting internal security policies violations.
Format: TOML file with regex patterns and metadata
Example: /etc/kindly-guard/custom-patterns.toml
max_scan_depth: usizeMaximum scan depth for nested structures
Default: 10 Security: Prevents algorithmic complexity attacks through deep nesting. Lower values are more secure but may miss deeply nested threats. Range: 1-100 (recommend 5-20 for most use cases) Warning: Values > 50 may cause performance issues
enable_event_buffer: boolEnable high-performance event buffer
Default: false (standard mode) Security: Enables advanced correlation and pattern matching. Provides “purple shield” mode with enhanced threat detection. Requirements: Additional memory (10-50MB depending on load)
max_content_size: usizeMaximum content size to scan (in bytes)
Default: 5MB (5,242,880 bytes) Security: Prevents DoS attacks through large payload scanning. Content larger than this will be rejected with a DosPotential threat. Range: 1KB-100MB (recommend 1-10MB for most use cases) Trade-off: Larger values allow bigger legitimate payloads but increase DoS risk
max_input_size: Option<usize>Maximum input size to scan (alias for max_content_size)
Default: Uses max_content_size value Security: Some tests expect this field name. This is an alias for backwards compatibility.
Trait Implementations§
Source§impl Clone for ScannerConfig
impl Clone for ScannerConfig
Source§fn clone(&self) -> ScannerConfig
fn clone(&self) -> ScannerConfig
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 ScannerConfig
impl Debug for ScannerConfig
Source§impl Default for ScannerConfig
impl Default for ScannerConfig
Source§fn default() -> ScannerConfig
fn default() -> ScannerConfig
Source§impl<'de> Deserialize<'de> for ScannerConfig
impl<'de> Deserialize<'de> for ScannerConfig
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<ScannerConfig, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<ScannerConfig, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl Serialize for ScannerConfig
impl Serialize for ScannerConfig
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Auto Trait Implementations§
impl Freeze for ScannerConfig
impl RefUnwindSafe for ScannerConfig
impl Send for ScannerConfig
impl Sync for ScannerConfig
impl Unpin for ScannerConfig
impl UnsafeUnpin for ScannerConfig
impl UnwindSafe for ScannerConfig
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,
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