pub enum SandboxPolicy {
ReadOnly {
network_access: bool,
network_allowlist: Vec<NetworkAllowlistEntry>,
},
WorkspaceWrite {
writable_roots: Vec<WritableRoot>,
network_access: bool,
network_allowlist: Vec<NetworkAllowlistEntry>,
sensitive_paths: Option<Vec<SensitivePath>>,
resource_limits: ResourceLimits,
seccomp_profile: SeccompProfile,
exclude_tmpdir_env_var: bool,
exclude_slash_tmp: bool,
},
DangerFullAccess,
ExternalSandbox {
description: String,
},
}Expand description
Sandbox policy determining what operations are permitted during execution.
This follows the Codex sandboxing model with three main variants:
- ReadOnly: Only read operations allowed (safe for viewing files)
- WorkspaceWrite: Can write within specified directories
- DangerFullAccess: No restrictions (dangerous, requires explicit approval)
The field guide’s three-question model:
- What is shared between this code and the host? (boundary)
- What can the code touch? (policy - this enum)
- What survives between runs? (lifecycle)
Variants§
ReadOnly
No write access to the filesystem; network access may be restricted or allowlisted.
Fields
network_allowlist: Vec<NetworkAllowlistEntry>Domain-based network egress allowlist.
WorkspaceWrite
Write access limited to the specified roots; network controlled by allowlist.
Fields
writable_roots: Vec<WritableRoot>Directories where write access is permitted.
network_access: boolWhether network access is allowed (legacy boolean, use network_allowlist for fine-grained control).
network_allowlist: Vec<NetworkAllowlistEntry>Domain-based network egress allowlist. When non-empty, only connections to these destinations are permitted. Following field guide: “Default-deny outbound network, then allowlist.”
sensitive_paths: Option<Vec<SensitivePath>>Sensitive paths to block (credentials, SSH keys, cloud configs). Following field guide: prevents “policy leakage” of credentials. Defaults to DEFAULT_SENSITIVE_PATHS if None.
resource_limits: ResourceLimitsResource limits (memory, PIDs, disk, CPU). Following field guide: prevents fork bombs, memory exhaustion.
seccomp_profile: SeccompProfileSeccomp-BPF profile for Linux syscall filtering. Following field guide: “Landlock + seccomp is the recommended Linux pattern.”
DangerFullAccess
Full access - no sandbox restrictions applied. Use with extreme caution.
ExternalSandbox
External sandbox - the caller is responsible for sandbox setup.
Implementations§
Source§impl SandboxPolicy
impl SandboxPolicy
Sourcepub fn new_read_only_policy() -> Self
pub fn new_read_only_policy() -> Self
Create a new read-only policy (alias for backwards compatibility).
Sourcepub fn read_only_with_network(
network_allowlist: Vec<NetworkAllowlistEntry>,
) -> Self
pub fn read_only_with_network( network_allowlist: Vec<NetworkAllowlistEntry>, ) -> Self
Create a read-only policy with a network allowlist.
Sourcepub fn read_only_with_full_network() -> Self
pub fn read_only_with_full_network() -> Self
Create a read-only policy with full network access.
Sourcepub fn workspace_write(writable_roots: Vec<PathBuf>) -> Self
pub fn workspace_write(writable_roots: Vec<PathBuf>) -> Self
Create a workspace-write policy with specified roots. Uses default sensitive path blocking and strict seccomp profile.
Sourcepub fn workspace_write_with_sensitive_paths(
writable_roots: Vec<PathBuf>,
sensitive_paths: Vec<SensitivePath>,
) -> Self
pub fn workspace_write_with_sensitive_paths( writable_roots: Vec<PathBuf>, sensitive_paths: Vec<SensitivePath>, ) -> Self
Create a workspace-write policy with custom sensitive path settings.
Sourcepub fn workspace_write_full(
writable_roots: Vec<PathBuf>,
network_allowlist: Vec<NetworkAllowlistEntry>,
sensitive_paths: Option<Vec<SensitivePath>>,
resource_limits: ResourceLimits,
seccomp_profile: SeccompProfile,
) -> Self
pub fn workspace_write_full( writable_roots: Vec<PathBuf>, network_allowlist: Vec<NetworkAllowlistEntry>, sensitive_paths: Option<Vec<SensitivePath>>, resource_limits: ResourceLimits, seccomp_profile: SeccompProfile, ) -> Self
Create a fully-configured workspace-write policy.
Sourcepub fn full_access() -> Self
pub fn full_access() -> Self
Create a full-access policy (dangerous).
Sourcepub fn has_full_network_access(&self) -> bool
pub fn has_full_network_access(&self) -> bool
Check if the policy allows full network access (unrestricted).
Sourcepub fn has_network_allowlist(&self) -> bool
pub fn has_network_allowlist(&self) -> bool
Check if the policy has a network allowlist (domain-restricted access).
Sourcepub fn network_allowlist(&self) -> &[NetworkAllowlistEntry]
pub fn network_allowlist(&self) -> &[NetworkAllowlistEntry]
Get the network allowlist entries, if any.
Sourcepub fn is_network_allowed(&self, domain: &str, port: u16) -> bool
pub fn is_network_allowed(&self, domain: &str, port: u16) -> bool
Check if network access to a specific domain:port is allowed.
Sourcepub fn is_path_readable(&self, path: &Path) -> bool
pub fn is_path_readable(&self, path: &Path) -> bool
Check if read access to a path is allowed under this policy.
Sourcepub fn resource_limits(&self) -> ResourceLimits
pub fn resource_limits(&self) -> ResourceLimits
Get the resource limits for this policy.
Sourcepub fn is_path_writable(&self, path: &Path, cwd: &Path) -> bool
pub fn is_path_writable(&self, path: &Path, cwd: &Path) -> bool
Check if a path is writable under this policy.
Sourcepub fn description(&self) -> &'static str
pub fn description(&self) -> &'static str
Get a human-readable description of the policy.
Trait Implementations§
Source§impl Clone for SandboxPolicy
impl Clone for SandboxPolicy
Source§fn clone(&self) -> SandboxPolicy
fn clone(&self) -> SandboxPolicy
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for SandboxPolicy
impl Debug for SandboxPolicy
Source§impl Default for SandboxPolicy
impl Default for SandboxPolicy
Source§impl<'de> Deserialize<'de> for SandboxPolicy
impl<'de> Deserialize<'de> for SandboxPolicy
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for SandboxPolicy
Source§impl PartialEq for SandboxPolicy
impl PartialEq for SandboxPolicy
Source§impl Serialize for SandboxPolicy
impl Serialize for SandboxPolicy
impl StructuralPartialEq for SandboxPolicy
Auto Trait Implementations§
impl Freeze for SandboxPolicy
impl RefUnwindSafe for SandboxPolicy
impl Send for SandboxPolicy
impl Sync for SandboxPolicy
impl Unpin for SandboxPolicy
impl UnsafeUnpin for SandboxPolicy
impl UnwindSafe for SandboxPolicy
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,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.