SanitizationEngine

Struct SanitizationEngine 

Source
pub struct SanitizationEngine { /* private fields */ }
Expand description

Sanitization engine for cleaning input before LLM processing

Implementations§

Source§

impl SanitizationEngine

Source

pub fn new(config: LLMSecurityConfig) -> Self

Create a new sanitization engine

Source

pub fn apply_sanitization(&self, code: &str) -> String

Apply sanitization to remove dangerous patterns

Source

pub fn wrap_code_safely(&self, code: &str) -> String

Wrap code with protective delimiters

Source

pub fn extract_code_from_response(&self, wrapped_code: &str) -> String

Extract code from response, stripping protective wrappers

Source

pub fn generate_secure_system_prompt(&self, base_prompt: &str) -> String

Generate secure system prompt with anti-injection measures

Source

pub fn sanitize_comprehensive(&self, code: &str) -> Result<String, String>

Comprehensive sanitization with size validation

Source

pub fn validate_and_sanitize(&self, input: &str) -> Result<String, String>

Validate and sanitize input for LLM processing

Source

pub fn contains_dangerous_patterns(&self, input: &str) -> bool

Check if input contains potentially dangerous patterns

Source

pub fn get_sanitization_stats( &self, original: &str, sanitized: &str, ) -> SanitizationStats

Get sanitization statistics

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.