pub struct SecurityConfig {
pub max_file_size: u64,
pub max_total_size: u64,
pub max_compression_ratio: f64,
pub max_file_count: usize,
pub max_path_depth: usize,
pub allowed: AllowedFeatures,
pub preserve_permissions: bool,
pub allowed_extensions: Vec<String>,
pub banned_path_components: Vec<String>,
}Expand description
Security configuration with default-deny settings.
This configuration controls various security checks performed during archive extraction to prevent common vulnerabilities.
§Performance Note
This struct contains heap-allocated collections (Vec<String>). For
performance, pass by reference (&SecurityConfig) rather than cloning. If
shared ownership is needed across threads, consider wrapping in
Arc<SecurityConfig>.
§Examples
use exarch_core::SecurityConfig;
// Use secure defaults
let config = SecurityConfig::default();
// Customize for specific needs
let custom = SecurityConfig {
max_file_size: 100 * 1024 * 1024, // 100 MB
max_total_size: 1024 * 1024 * 1024, // 1 GB
..Default::default()
};Fields§
§max_file_size: u64Maximum size for a single file in bytes.
max_total_size: u64Maximum total size for all extracted files in bytes.
max_compression_ratio: f64Maximum compression ratio allowed (uncompressed / compressed).
max_file_count: usizeMaximum number of files that can be extracted.
max_path_depth: usizeMaximum path depth allowed.
allowed: AllowedFeaturesFeature flags controlling what archive features are allowed.
Use this to enable symlinks, hardlinks, absolute paths, etc.
preserve_permissions: boolPreserve file permissions from archive.
allowed_extensions: Vec<String>List of allowed file extensions (empty = allow all).
banned_path_components: Vec<String>List of banned path components (e.g., “.git”, “.ssh”).
Implementations§
Source§impl SecurityConfig
impl SecurityConfig
Sourcepub fn permissive() -> Self
pub fn permissive() -> Self
Creates a permissive configuration for trusted archives.
This configuration allows symlinks, hardlinks, and absolute paths. Use only when extracting archives from trusted sources.
Sourcepub fn is_path_component_allowed(&self, component: &str) -> bool
pub fn is_path_component_allowed(&self, component: &str) -> bool
Validates whether a path component is allowed.
Comparison is case-insensitive to prevent bypass on case-insensitive filesystems (Windows, macOS default).
Sourcepub fn is_extension_allowed(&self, extension: &str) -> bool
pub fn is_extension_allowed(&self, extension: &str) -> bool
Validates whether a file extension is allowed.
Trait Implementations§
Source§impl Clone for SecurityConfig
impl Clone for SecurityConfig
Source§fn clone(&self) -> SecurityConfig
fn clone(&self) -> SecurityConfig
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for SecurityConfig
impl Debug for SecurityConfig
Source§impl Default for SecurityConfig
impl Default for SecurityConfig
Source§fn default() -> Self
fn default() -> Self
Creates a SecurityConfig with secure default settings.
Default values:
max_file_size: 50 MBmax_total_size: 500 MBmax_compression_ratio: 100.0max_file_count: 10,000max_path_depth: 32allowed: All features disabled (deny-by-default)preserve_permissions: falseallowed_extensions: empty (allow all)banned_path_components:[".git", ".ssh", ".gnupg", ".aws", ".kube", ".docker", ".env"]