1use serde::{Deserialize, Serialize};
4use std::time::Duration;
5
6#[derive(Debug, Clone, Serialize, Deserialize, Default)]
8pub struct AimdsConfig {
9 #[serde(default)]
10 pub detection: DetectionConfig,
11 #[serde(default)]
12 pub analysis: AnalysisConfig,
13 #[serde(default)]
14 pub response: ResponseConfig,
15 #[serde(default)]
16 pub system: SystemConfig,
17}
18
19#[derive(Debug, Clone, Serialize, Deserialize)]
21pub struct DetectionConfig {
22 pub pattern_matching_enabled: bool,
23 pub sanitization_enabled: bool,
24 pub confidence_threshold: f64,
25 pub max_pattern_complexity: usize,
26 pub cache_size: usize,
27}
28
29impl Default for DetectionConfig {
30 fn default() -> Self {
31 Self {
32 pattern_matching_enabled: true,
33 sanitization_enabled: true,
34 confidence_threshold: 0.75,
35 max_pattern_complexity: 1000,
36 cache_size: 10000,
37 }
38 }
39}
40
41#[derive(Debug, Clone, Serialize, Deserialize)]
43pub struct AnalysisConfig {
44 pub behavioral_analysis_enabled: bool,
45 pub policy_verification_enabled: bool,
46 pub ltl_checking_enabled: bool,
47 pub threat_score_threshold: f64,
48 pub max_temporal_window: Duration,
49}
50
51impl Default for AnalysisConfig {
52 fn default() -> Self {
53 Self {
54 behavioral_analysis_enabled: true,
55 policy_verification_enabled: true,
56 ltl_checking_enabled: true,
57 threat_score_threshold: 0.8,
58 max_temporal_window: Duration::from_secs(3600),
59 }
60 }
61}
62
63#[derive(Debug, Clone, Serialize, Deserialize)]
65pub struct ResponseConfig {
66 pub meta_learning_enabled: bool,
67 pub adaptive_responses_enabled: bool,
68 pub auto_mitigation_enabled: bool,
69 pub learning_rate: f64,
70 pub response_timeout: Duration,
71}
72
73impl Default for ResponseConfig {
74 fn default() -> Self {
75 Self {
76 meta_learning_enabled: true,
77 adaptive_responses_enabled: true,
78 auto_mitigation_enabled: true,
79 learning_rate: 0.01,
80 response_timeout: Duration::from_secs(5),
81 }
82 }
83}
84
85#[derive(Debug, Clone, Serialize, Deserialize)]
87pub struct SystemConfig {
88 pub max_concurrent_requests: usize,
89 pub request_timeout: Duration,
90 pub enable_metrics: bool,
91 pub enable_tracing: bool,
92 pub log_level: String,
93}
94
95impl Default for SystemConfig {
96 fn default() -> Self {
97 Self {
98 max_concurrent_requests: 1000,
99 request_timeout: Duration::from_secs(30),
100 enable_metrics: true,
101 enable_tracing: true,
102 log_level: "info".to_string(),
103 }
104 }
105}
106
107#[cfg(test)]
108mod tests {
109 use super::*;
110
111 #[test]
112 fn test_default_config() {
113 let config = AimdsConfig::default();
114 assert!(config.detection.pattern_matching_enabled);
115 assert!(config.analysis.behavioral_analysis_enabled);
116 assert!(config.response.meta_learning_enabled);
117 }
118
119 #[test]
120 fn test_config_serialization() {
121 let config = AimdsConfig::default();
122 let json = serde_json::to_string(&config).unwrap();
123 let deserialized: AimdsConfig = serde_json::from_str(&json).unwrap();
124
125 assert_eq!(
126 config.detection.confidence_threshold,
127 deserialized.detection.confidence_threshold
128 );
129 }
130}