Skip to main content

security_rust/
result.rs

1// Copyright (c) 2026 erik <erik@erik.xyz> — https://erik.xyz
2
3use std::fmt;
4
5#[derive(Debug, Clone, PartialEq, Eq)]
6pub enum Severity {
7    Critical,
8    High,
9    Medium,
10    Low,
11}
12
13impl fmt::Display for Severity {
14    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
15        match self {
16            Severity::Critical => write!(f, "CRITICAL"),
17            Severity::High => write!(f, "HIGH"),
18            Severity::Medium => write!(f, "MEDIUM"),
19            Severity::Low => write!(f, "LOW"),
20        }
21    }
22}
23
24#[derive(Debug, Clone, PartialEq, Eq)]
25pub enum AttackCategory {
26    Injection,
27    Protocol,
28    Data,
29    File,
30}
31
32#[derive(Debug, Clone)]
33pub struct DetectionResult {
34    pub attack_type: String,
35    pub category: AttackCategory,
36    pub severity: Severity,
37    pub matched_pattern: String,
38    pub offset: usize,
39    pub message: String,
40}