pub struct SecurityAuditStats {
pub active_sessions: u64,
pub failed_logins_24h: u64,
pub successful_logins_24h: u64,
pub unique_users_24h: u64,
pub token_issued_24h: u64,
pub password_resets_24h: u64,
pub admin_actions_24h: u64,
pub security_alerts_24h: u64,
pub collection_timestamp: DateTime<Utc>,
}
Expand description
Security audit statistics aggregated from audit logs Provides comprehensive security metrics for monitoring and incident response
Fields§
§active_sessions: u64
§failed_logins_24h: u64
§successful_logins_24h: u64
§unique_users_24h: u64
§token_issued_24h: u64
§password_resets_24h: u64
§admin_actions_24h: u64
§security_alerts_24h: u64
§collection_timestamp: DateTime<Utc>
Implementations§
Source§impl SecurityAuditStats
impl SecurityAuditStats
Sourcepub fn security_score(&self) -> f64
pub fn security_score(&self) -> f64
Calculate security score based on current metrics Returns a value between 0.0 (critical) and 1.0 (excellent)
Sourcepub fn requires_immediate_attention(&self) -> bool
pub fn requires_immediate_attention(&self) -> bool
Determines if the current security metrics require immediate attention.
This function analyzes various security metrics to identify potential security incidents that require immediate administrative action.
§Returns
true
if immediate security attention is requiredfalse
if security metrics are within acceptable ranges
§Criteria for Immediate Attention
- More than 100 failed login attempts in 24 hours (potential brute force)
- More than 5 security alerts in 24 hours (multiple incidents)
- Security score below 0.3 (critical security threshold)
§Example
if security_stats.requires_immediate_attention() {
// Trigger security alerts, notify administrators
alert_security_team(&security_stats);
}
Sourcepub fn security_alert_message(&self) -> Option<String>
pub fn security_alert_message(&self) -> Option<String>
Generates a detailed security alert message if immediate attention is required.
This function creates a human-readable alert message describing the specific security concerns that triggered the alert. The message includes specific metrics and recommended actions.
§Returns
Some(String)
containing the alert message if attention is requiredNone
if no immediate security concerns are detected
§Alert Content
The alert message includes:
- Current security score
- Specific metrics that triggered the alert
- Severity indicators
- Recommended immediate actions
§Example
if let Some(alert) = security_stats.security_alert_message() {
log::error!("Security Alert: {}", alert);
notify_administrators(&alert);
}
Trait Implementations§
Source§impl Clone for SecurityAuditStats
impl Clone for SecurityAuditStats
Source§fn clone(&self) -> SecurityAuditStats
fn clone(&self) -> SecurityAuditStats
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for SecurityAuditStats
impl Debug for SecurityAuditStats
Source§impl<'de> Deserialize<'de> for SecurityAuditStats
impl<'de> Deserialize<'de> for SecurityAuditStats
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for SecurityAuditStats
impl RefUnwindSafe for SecurityAuditStats
impl Send for SecurityAuditStats
impl Sync for SecurityAuditStats
impl Unpin for SecurityAuditStats
impl UnwindSafe for SecurityAuditStats
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
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>
Converts
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>
Converts
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