1#![deny(clippy::unwrap_used)]
14#![deny(clippy::panic)]
15#![warn(missing_docs)]
16
17pub mod access_control;
18pub mod anonymization;
19pub mod audit;
20pub mod compliance;
21pub mod encryption;
22pub mod error;
23pub mod lineage;
24pub mod multitenancy;
25pub mod scanning;
26
27pub use error::{Result, SecurityError};
28
29#[derive(Debug, Clone)]
31pub struct SecurityConfig {
32 pub encryption_enabled: bool,
34 pub access_control_enabled: bool,
36 pub audit_logging_enabled: bool,
38 pub lineage_tracking_enabled: bool,
40 pub multitenancy_enabled: bool,
42}
43
44impl Default for SecurityConfig {
45 fn default() -> Self {
46 Self {
47 encryption_enabled: true,
48 access_control_enabled: true,
49 audit_logging_enabled: true,
50 lineage_tracking_enabled: true,
51 multitenancy_enabled: false,
52 }
53 }
54}
55
56impl SecurityConfig {
57 pub fn new() -> Self {
59 Self::default()
60 }
61
62 pub fn with_encryption(mut self, enabled: bool) -> Self {
64 self.encryption_enabled = enabled;
65 self
66 }
67
68 pub fn with_access_control(mut self, enabled: bool) -> Self {
70 self.access_control_enabled = enabled;
71 self
72 }
73
74 pub fn with_audit_logging(mut self, enabled: bool) -> Self {
76 self.audit_logging_enabled = enabled;
77 self
78 }
79
80 pub fn with_lineage_tracking(mut self, enabled: bool) -> Self {
82 self.lineage_tracking_enabled = enabled;
83 self
84 }
85
86 pub fn with_multitenancy(mut self, enabled: bool) -> Self {
88 self.multitenancy_enabled = enabled;
89 self
90 }
91
92 pub fn secure() -> Self {
94 Self {
95 encryption_enabled: true,
96 access_control_enabled: true,
97 audit_logging_enabled: true,
98 lineage_tracking_enabled: true,
99 multitenancy_enabled: true,
100 }
101 }
102
103 pub fn minimal() -> Self {
105 Self {
106 encryption_enabled: true,
107 access_control_enabled: false,
108 audit_logging_enabled: false,
109 lineage_tracking_enabled: false,
110 multitenancy_enabled: false,
111 }
112 }
113}
114
115#[cfg(test)]
116mod tests {
117 use super::*;
118
119 #[test]
120 fn test_security_config() {
121 let config = SecurityConfig::new()
122 .with_encryption(true)
123 .with_access_control(true);
124
125 assert!(config.encryption_enabled);
126 assert!(config.access_control_enabled);
127 }
128
129 #[test]
130 fn test_secure_config() {
131 let config = SecurityConfig::secure();
132 assert!(config.encryption_enabled);
133 assert!(config.access_control_enabled);
134 assert!(config.audit_logging_enabled);
135 assert!(config.lineage_tracking_enabled);
136 assert!(config.multitenancy_enabled);
137 }
138
139 #[test]
140 fn test_minimal_config() {
141 let config = SecurityConfig::minimal();
142 assert!(config.encryption_enabled);
143 assert!(!config.access_control_enabled);
144 assert!(!config.audit_logging_enabled);
145 }
146}