spawn_access_control/
lib.rs

1//! # Spawn Access Control
2//! 
3//! Gelişmiş güvenlik ve erişim kontrolü için Rust tabanlı kütüphane.
4//! 
5//! ## Özellikler
6//! 
7//! - Role-based access control (RBAC)
8//! - Davranışsal analiz ve anomali tespiti
9//! - Makine öğrenimi destekli güvenlik
10//! - Gerçek zamanlı alert sistemi
11//! - Zaman serisi analizi ve tahminleme
12//! - WebAssembly desteği
13
14// Temel modüller
15pub mod access_control;
16pub mod access_manager;
17pub mod alert_analyzer;
18pub mod alert_ml;
19pub mod alert_storage;
20pub mod alert_system;
21pub mod audit;
22pub mod behavioral;
23pub mod error;
24pub mod geo_analyzer;
25pub mod metrics;
26pub mod ml_analyzer;
27pub mod ml_metrics;
28pub mod monitoring;
29pub mod security_analyzer;
30pub mod time_series_analyzer;
31pub mod model_explainer;
32pub mod model_optimizer;
33pub mod metrics_exporter;
34
35// Notification modülü
36pub mod notification {
37    pub mod email;
38    pub mod slack;
39    pub use email::EmailNotificationHandler;
40    pub use slack::SlackNotificationHandler;
41}
42
43// WASM desteği
44#[cfg(target_arch = "wasm32")]
45mod wasm;
46
47// Temel trait'ler ve tipler
48pub use chrono::{DateTime, Utc, Duration, Timelike, Datelike};
49pub use serde::{Serialize, Deserialize};
50pub use async_trait::async_trait;
51pub use std::hash::Hash;
52
53// Re-exports
54pub use crate::{
55    access_control::{AccessControl, Permission, Role, Resource},
56    access_manager::AccessManager,
57    alert_analyzer::{AlertAnalyzer, AlertPattern, PatternType},
58    alert_system::{AlertNotification, AlertSeverity, NotificationHandler, EscalationLevel},
59    monitoring::{ModelHealth, HealthStatus, AlertSeverity as MonitoringAlertSeverity},
60    security_analyzer::{SecurityAnalyzer, SecurityReport},
61};
62
63// Prelude modülü
64pub mod prelude {
65    pub use crate::{
66        AccessControl, Permission, Role, Resource,
67        AlertAnalyzer, AlertPattern, PatternType,
68        AlertNotification, AlertSeverity, EscalationLevel,
69        ModelHealth, HealthStatus,
70        SecurityReport,
71    };
72}
73
74// Error tipi
75pub use error::Error;
76pub type Result<T> = std::result::Result<T, Error>;
77
78// Genel konfigürasyon yapısı
79#[derive(Debug, Clone, Serialize, Deserialize)]
80pub struct Config {
81    pub database_url: String,
82    #[serde(with = "duration_serde")]
83    pub cache_ttl: Duration,
84    pub max_retries: u32,
85    pub alert_threshold: f64,
86    pub enable_ml: bool,
87}
88
89// Duration serileştirme modülü
90mod duration_serde {
91    use chrono::Duration;
92    use serde::{Deserialize, Deserializer, Serialize, Serializer};
93
94    pub fn serialize<S>(duration: &Duration, serializer: S) -> Result<S::Ok, S::Error>
95    where
96        S: Serializer,
97    {
98        duration.num_seconds().serialize(serializer)
99    }
100
101    pub fn deserialize<'de, D>(deserializer: D) -> Result<Duration, D::Error>
102    where
103        D: Deserializer<'de>,
104    {
105        let seconds = i64::deserialize(deserializer)?;
106        Ok(Duration::seconds(seconds))
107    }
108}
109
110impl Default for Config {
111    fn default() -> Self {
112        Self {
113            database_url: "mongodb://localhost:27017".to_string(),
114            cache_ttl: Duration::minutes(30),
115            max_retries: 3,
116            alert_threshold: 0.8,
117            enable_ml: true,
118        }
119    }
120}
121
122// Error dönüşümleri için
123impl From<serde_json::Error> for Error {
124    fn from(err: serde_json::Error) -> Self {
125        Error::Serialization(err.to_string())
126    }
127}
128
129impl From<std::io::Error> for Error {
130    fn from(err: std::io::Error) -> Self {
131        Error::Io(err.to_string())
132    }
133}
134
135impl From<Box<dyn std::error::Error>> for Error {
136    fn from(err: Box<dyn std::error::Error>) -> Self {
137        Error::Database(err.to_string())
138    }
139}
140
141// Re-export if needed
142pub use model_explainer::{SecurityImpactAnalysis, RiskFactor};