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