pub struct SanitizationEngine { /* private fields */ }Expand description
Sanitization engine for cleaning input before LLM processing
Implementations§
Source§impl SanitizationEngine
impl SanitizationEngine
Sourcepub fn new(config: LLMSecurityConfig) -> Self
pub fn new(config: LLMSecurityConfig) -> Self
Create a new sanitization engine
Sourcepub fn apply_sanitization(&self, code: &str) -> String
pub fn apply_sanitization(&self, code: &str) -> String
Apply sanitization to remove dangerous patterns
Sourcepub fn wrap_code_safely(&self, code: &str) -> String
pub fn wrap_code_safely(&self, code: &str) -> String
Wrap code with protective delimiters
Sourcepub fn extract_code_from_response(&self, wrapped_code: &str) -> String
pub fn extract_code_from_response(&self, wrapped_code: &str) -> String
Extract code from response, stripping protective wrappers
Sourcepub fn generate_secure_system_prompt(&self, base_prompt: &str) -> String
pub fn generate_secure_system_prompt(&self, base_prompt: &str) -> String
Generate secure system prompt with anti-injection measures
Sourcepub fn sanitize_comprehensive(&self, code: &str) -> Result<String, String>
pub fn sanitize_comprehensive(&self, code: &str) -> Result<String, String>
Comprehensive sanitization with size validation
Sourcepub fn validate_and_sanitize(&self, input: &str) -> Result<String, String>
pub fn validate_and_sanitize(&self, input: &str) -> Result<String, String>
Validate and sanitize input for LLM processing
Sourcepub fn contains_dangerous_patterns(&self, input: &str) -> bool
pub fn contains_dangerous_patterns(&self, input: &str) -> bool
Check if input contains potentially dangerous patterns
Sourcepub fn get_sanitization_stats(
&self,
original: &str,
sanitized: &str,
) -> SanitizationStats
pub fn get_sanitization_stats( &self, original: &str, sanitized: &str, ) -> SanitizationStats
Get sanitization statistics
Auto Trait Implementations§
impl Freeze for SanitizationEngine
impl RefUnwindSafe for SanitizationEngine
impl Send for SanitizationEngine
impl Sync for SanitizationEngine
impl Unpin for SanitizationEngine
impl UnwindSafe for SanitizationEngine
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