1#![deny(clippy::unwrap_used)]
28#![deny(clippy::panic)]
29#![warn(missing_docs)]
30
31#[cfg(feature = "enterprise")]
32pub mod access_control;
33#[cfg(feature = "enterprise")]
34pub mod anonymization;
35#[cfg(feature = "attestation")]
36pub mod attestation;
37#[cfg(feature = "enterprise")]
38pub mod audit;
39#[cfg(feature = "enterprise")]
40pub mod compliance;
41#[cfg(feature = "enterprise")]
42pub mod encryption;
43pub mod error;
44#[cfg(feature = "enterprise")]
45pub mod lineage;
46#[cfg(feature = "enterprise")]
47pub mod multitenancy;
48#[cfg(feature = "enterprise")]
49pub mod scanning;
50
51pub use error::{Result, SecurityError};
52
53#[derive(Debug, Clone)]
55pub struct SecurityConfig {
56 pub encryption_enabled: bool,
58 pub access_control_enabled: bool,
60 pub audit_logging_enabled: bool,
62 pub lineage_tracking_enabled: bool,
64 pub multitenancy_enabled: bool,
66}
67
68impl Default for SecurityConfig {
69 fn default() -> Self {
70 Self {
71 encryption_enabled: true,
72 access_control_enabled: true,
73 audit_logging_enabled: true,
74 lineage_tracking_enabled: true,
75 multitenancy_enabled: false,
76 }
77 }
78}
79
80impl SecurityConfig {
81 pub fn new() -> Self {
83 Self::default()
84 }
85
86 pub fn with_encryption(mut self, enabled: bool) -> Self {
88 self.encryption_enabled = enabled;
89 self
90 }
91
92 pub fn with_access_control(mut self, enabled: bool) -> Self {
94 self.access_control_enabled = enabled;
95 self
96 }
97
98 pub fn with_audit_logging(mut self, enabled: bool) -> Self {
100 self.audit_logging_enabled = enabled;
101 self
102 }
103
104 pub fn with_lineage_tracking(mut self, enabled: bool) -> Self {
106 self.lineage_tracking_enabled = enabled;
107 self
108 }
109
110 pub fn with_multitenancy(mut self, enabled: bool) -> Self {
112 self.multitenancy_enabled = enabled;
113 self
114 }
115
116 pub fn secure() -> Self {
118 Self {
119 encryption_enabled: true,
120 access_control_enabled: true,
121 audit_logging_enabled: true,
122 lineage_tracking_enabled: true,
123 multitenancy_enabled: true,
124 }
125 }
126
127 pub fn minimal() -> Self {
129 Self {
130 encryption_enabled: true,
131 access_control_enabled: false,
132 audit_logging_enabled: false,
133 lineage_tracking_enabled: false,
134 multitenancy_enabled: false,
135 }
136 }
137}
138
139#[cfg(test)]
140mod tests {
141 use super::*;
142
143 #[test]
144 fn test_security_config() {
145 let config = SecurityConfig::new()
146 .with_encryption(true)
147 .with_access_control(true);
148
149 assert!(config.encryption_enabled);
150 assert!(config.access_control_enabled);
151 }
152
153 #[test]
154 fn test_secure_config() {
155 let config = SecurityConfig::secure();
156 assert!(config.encryption_enabled);
157 assert!(config.access_control_enabled);
158 assert!(config.audit_logging_enabled);
159 assert!(config.lineage_tracking_enabled);
160 assert!(config.multitenancy_enabled);
161 }
162
163 #[test]
164 fn test_minimal_config() {
165 let config = SecurityConfig::minimal();
166 assert!(config.encryption_enabled);
167 assert!(!config.access_control_enabled);
168 assert!(!config.audit_logging_enabled);
169 }
170}