use security_core::severity::SecuritySeverity;
use security_events::{
emit::emit_security_event,
event::{EventOutcome, SecurityEvent},
kind::EventKind,
};
#[non_exhaustive]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
pub enum ViolationKind {
UnknownField,
BodyTooLarge,
InvalidContentType,
SyntaxViolation,
SemanticViolation,
NestingTooDeep,
TooManyFields,
InvalidPathParam,
InvalidQueryParam,
}
#[derive(Clone, Debug)]
pub struct BoundaryViolation {
pub kind: ViolationKind,
pub reason_code: &'static str,
}
impl BoundaryViolation {
#[must_use]
pub fn new(kind: ViolationKind, reason_code: &'static str) -> Self {
Self { kind, reason_code }
}
pub fn emit(&self) {
let event = SecurityEvent::new(
EventKind::BoundaryViolation,
SecuritySeverity::Medium,
EventOutcome::Blocked,
);
emit_security_event(event);
}
}