systemprompt_api/services/gateway/safety/
mod.rs1pub mod heuristic;
2pub mod null;
3
4use async_trait::async_trait;
5
6use super::protocol::canonical::CanonicalRequest;
7use super::protocol::canonical_response::CanonicalResponse;
8
9#[derive(Debug, Clone, Copy, PartialEq, Eq)]
10pub enum Severity {
11 Low,
12 Medium,
13 High,
14}
15
16impl Severity {
17 pub const fn as_str(self) -> &'static str {
18 match self {
19 Self::Low => "low",
20 Self::Medium => "medium",
21 Self::High => "high",
22 }
23 }
24}
25
26#[derive(Debug, Clone)]
27pub struct Finding {
28 pub phase: &'static str,
29 pub severity: Severity,
30 pub category: String,
31 pub excerpt: Option<String>,
32 pub scanner: &'static str,
33}
34
35#[async_trait]
36pub trait SafetyScanner: Send + Sync {
37 fn name(&self) -> &'static str;
38 async fn scan_request(&self, req: &CanonicalRequest) -> Vec<Finding>;
39 async fn scan_response_final(&self, response: &CanonicalResponse) -> Vec<Finding>;
40}
41
42pub use heuristic::HeuristicScanner;
43pub use null::NullScanner;