pub struct SandboxPolicy {
pub allowed_paths: Vec<AllowedPath>,
pub allow_network: bool,
pub network_rules: Vec<NetworkRule>,
pub allow_process_spawn: bool,
pub env: HashMap<String, String>,
}sandbox only.Expand description
A declarative sandbox policy describing allowed operations.
Constructed via SandboxPolicyBuilder. Defaults to deny-all when
no permissions are granted.
§Network Access
Network access has two levels of control:
-
Binary (
allow_network): Whentrue, all network access is allowed. Whenfalse, all network is blocked. Works on all platforms. -
Domain allowlist (
network_rules): Whenallow_networkisfalsebutnetwork_rulesis non-empty, only the specified domains/ports are allowed. Only enforced on macOS (Seatbelt supports domain-level filtering). On Linux and Windows, non-emptynetwork_ruleswithallow_network = falseresults in all network being blocked — the rules are ignored with atracing::warn.
§Example
use adk_sandbox::sandbox::SandboxPolicyBuilder;
// Allow only OpenAI API access
let policy = SandboxPolicyBuilder::new()
.allow_read("/usr/lib")
.allow_domain("api.openai.com", &[443])
.allow_domain("cdn.openai.com", &[443])
.env("PATH", "/usr/bin")
.build();
assert!(!policy.allow_network); // full network is denied
assert_eq!(policy.network_rules.len(), 2); // but 2 domains are allowedFields§
§allowed_paths: Vec<AllowedPath>Filesystem paths the process may access.
allow_network: boolWhether the process may access the network (all domains/ports).
network_rules: Vec<NetworkRule>Per-domain network allowlist. Only used when allow_network is false.
Only enforced on macOS (Seatbelt). Linux/Windows ignore these rules
and fall back to binary network control.
allow_process_spawn: boolWhether the process may spawn child processes.
env: HashMap<String, String>Environment variables passed to the sandboxed process.
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<'de> Deserialize<'de> for SandboxPolicy
impl<'de> Deserialize<'de> for SandboxPolicy
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<SandboxPolicy, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<SandboxPolicy, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl PartialEq for SandboxPolicy
impl PartialEq for SandboxPolicy
Source§fn eq(&self, other: &SandboxPolicy) -> bool
fn eq(&self, other: &SandboxPolicy) -> bool
self and other values to be equal, and is used by ==.