pub struct Profiler { /* private fields */ }Expand description
Profiler manager for endpoint behavior learning and anomaly detection.
Implementations§
Source§impl Profiler
impl Profiler
Sourcepub fn new(config: ProfilerConfig) -> Self
pub fn new(config: ProfilerConfig) -> Self
Create a new profiler with the given configuration.
Sourcepub fn is_enabled(&self) -> bool
pub fn is_enabled(&self) -> bool
Check if profiling is enabled.
Sourcepub fn get_or_create_profile(&self, template: &str) -> Option<EndpointProfile>
pub fn get_or_create_profile(&self, template: &str) -> Option<EndpointProfile>
Get or create an endpoint profile.
Sourcepub fn update_profile(
&self,
template: &str,
payload_size: usize,
params: &[(&str, &str)],
content_type: Option<&str>,
)
pub fn update_profile( &self, template: &str, payload_size: usize, params: &[(&str, &str)], content_type: Option<&str>, )
Update an endpoint profile with request data.
Respects the freeze_after_samples setting to prevent model poisoning.
If a profile has reached the freeze threshold, updates are silently ignored.
Sourcepub fn update_response_profile(
&self,
template: &str,
response_size: usize,
status_code: u16,
content_type: Option<&str>,
)
pub fn update_response_profile( &self, template: &str, response_size: usize, status_code: u16, content_type: Option<&str>, )
Update an endpoint profile with response data.
Respects the freeze_after_samples setting to prevent model poisoning.
Sourcepub fn get_profiles(&self) -> Vec<EndpointProfile>
pub fn get_profiles(&self) -> Vec<EndpointProfile>
Get all profiles.
Sourcepub fn get_profile(&self, template: &str) -> Option<EndpointProfile>
pub fn get_profile(&self, template: &str) -> Option<EndpointProfile>
Get a specific profile by template.
Sourcepub fn profile_count(&self) -> usize
pub fn profile_count(&self) -> usize
Get the number of profiles.
Sourcepub fn learn_schema(&self, template: &str)
pub fn learn_schema(&self, template: &str)
Learn schema from a profile if it has enough samples.
Sourcepub fn get_schemas(&self) -> Vec<ParameterSchema>
pub fn get_schemas(&self) -> Vec<ParameterSchema>
Get all learned schemas.
Sourcepub fn get_schema(&self, template: &str) -> Option<ParameterSchema>
pub fn get_schema(&self, template: &str) -> Option<ParameterSchema>
Get a specific schema by template.
Sourcepub fn schema_count(&self) -> usize
pub fn schema_count(&self) -> usize
Get the number of schemas.
Sourcepub fn reset_profiles(&self)
pub fn reset_profiles(&self)
Reset all profiles (for testing).
Sourcepub fn reset_schemas(&self)
pub fn reset_schemas(&self)
Reset all schemas (for testing).
Sourcepub fn analyze_request(
&self,
template: &str,
payload_size: usize,
params: &[(&str, &str)],
content_type: Option<&str>,
) -> AnomalyResult
pub fn analyze_request( &self, template: &str, payload_size: usize, params: &[(&str, &str)], content_type: Option<&str>, ) -> AnomalyResult
Analyze a request against the learned profile.
Uses configurable thresholds for anomaly detection and optional PII redaction.
Sourcepub fn analyze_response(
&self,
template: &str,
response_size: usize,
status_code: u16,
content_type: Option<&str>,
) -> AnomalyResult
pub fn analyze_response( &self, template: &str, response_size: usize, status_code: u16, content_type: Option<&str>, ) -> AnomalyResult
Analyze a response against the learned profile.
Uses configurable thresholds for response size anomaly detection.
Sourcepub fn is_profile_frozen(&self, template: &str) -> bool
pub fn is_profile_frozen(&self, template: &str) -> bool
Check if a profile is frozen (no longer accepts updates).
Frozen baselines help prevent model poisoning attacks where attackers gradually shift the baseline to make malicious patterns appear normal.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Profiler
impl !RefUnwindSafe for Profiler
impl Send for Profiler
impl Sync for Profiler
impl Unpin for Profiler
impl UnsafeUnpin for Profiler
impl UnwindSafe for Profiler
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> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
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