pub struct FileSandboxConfig {
pub enabled: bool,
pub allowed_paths: Vec<PathBuf>,
}Expand description
Security configuration for file system operations. Controls which paths can be accessed by BACKUP, COPY, and EXPORT commands.
Disabled by default for backward compatibility in embedded mode. MUST be enabled for server mode with untrusted clients.
Fields§
§enabled: boolIf true, file operations are restricted to allowed_paths. If false, all paths are allowed (NOT RECOMMENDED for server mode).
allowed_paths: Vec<PathBuf>List of allowed base directories for file operations. Paths must be absolute and canonical. File operations are only allowed within these directories.
Implementations§
Source§impl FileSandboxConfig
impl FileSandboxConfig
Sourcepub fn sandboxed(paths: Vec<PathBuf>) -> Self
pub fn sandboxed(paths: Vec<PathBuf>) -> Self
Creates a sandboxed config that only allows operations in the specified directories.
Sourcepub fn default_for_mode(mode: DeploymentMode) -> Self
pub fn default_for_mode(mode: DeploymentMode) -> Self
Creates a config with appropriate defaults for the deployment mode.
§Security
- Embedded mode: Sandbox disabled (host application controls access)
- Server mode: Sandbox enabled with default paths
/var/lib/uni/dataand/var/lib/uni/backups
CWE-22 (Path Traversal): Server deployments MUST enable the sandbox to prevent arbitrary file read/write via BACKUP, COPY, and EXPORT commands.
Sourcepub fn security_warning(&self) -> Option<&'static str>
pub fn security_warning(&self) -> Option<&'static str>
Returns a security warning message if the sandbox is disabled.
Call this at startup to alert administrators about potential security risks.
Returns Some(message) if a warning should be displayed, None otherwise.
§Security
CWE-22 (Path Traversal), CWE-73 (External Control of File Name): Disabled sandbox allows unrestricted filesystem access for BACKUP, COPY, and EXPORT commands, which can lead to:
- Arbitrary file read/write in server deployments
- Data exfiltration to attacker-controlled paths
- Potential privilege escalation via file overwrites
§Example
if let Some(warning) = config.file_sandbox.security_warning() {
tracing::warn!(target: "uni_db::security", "{}", warning);
}Sourcepub fn is_potentially_insecure(&self) -> bool
pub fn is_potentially_insecure(&self) -> bool
Returns whether the sandbox is in a potentially insecure state.
Returns true if the sandbox is disabled or enabled with no allowed paths.
Trait Implementations§
Source§impl Clone for FileSandboxConfig
impl Clone for FileSandboxConfig
Source§fn clone(&self) -> FileSandboxConfig
fn clone(&self) -> FileSandboxConfig
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for FileSandboxConfig
impl Debug for FileSandboxConfig
Source§impl Default for FileSandboxConfig
impl Default for FileSandboxConfig
Source§fn default() -> FileSandboxConfig
fn default() -> FileSandboxConfig
Auto Trait Implementations§
impl Freeze for FileSandboxConfig
impl RefUnwindSafe for FileSandboxConfig
impl Send for FileSandboxConfig
impl Sync for FileSandboxConfig
impl Unpin for FileSandboxConfig
impl UnsafeUnpin for FileSandboxConfig
impl UnwindSafe for FileSandboxConfig
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more