pub struct SandboxPolicy {
pub network: NetworkPolicy,
pub filesystem: FilesystemPolicy,
pub environment: EnvironmentPolicy,
pub timeout: Duration,
pub max_stdout_bytes: usize,
pub max_stderr_bytes: usize,
pub working_directory: Option<PathBuf>,
}code only.Expand description
Sandbox policy describing the requested execution constraints.
Backends compare this policy against their BackendCapabilities and
reject execution if they cannot enforce a requested control.
§Example
use adk_code::SandboxPolicy;
let policy = SandboxPolicy::strict_rust();
assert_eq!(policy.max_stdout_bytes, 1_048_576);Fields§
§network: NetworkPolicyNetwork access policy.
filesystem: FilesystemPolicyFilesystem access policy.
environment: EnvironmentPolicyEnvironment variable access policy.
timeout: DurationMaximum execution duration.
max_stdout_bytes: usizeMaximum bytes captured from stdout before truncation.
max_stderr_bytes: usizeMaximum bytes captured from stderr before truncation.
working_directory: Option<PathBuf>Working directory for execution, if any.
Implementations§
Source§impl SandboxPolicy
impl SandboxPolicy
Sourcepub fn strict_rust() -> SandboxPolicy
pub fn strict_rust() -> SandboxPolicy
Strict policy for Rust sandbox execution.
- No network access
- No filesystem access
- No environment variables
- 30-second timeout
- 1 MB stdout/stderr limits
Sourcepub fn host_local() -> SandboxPolicy
pub fn host_local() -> SandboxPolicy
Host-local policy for backends that run on the host without isolation.
Unlike strict_rust, this policy uses
NetworkPolicy::Enabled and FilesystemPolicy::None so that
host-local backends (which cannot enforce network or filesystem
restrictions) pass policy validation. The trade-off is that the
executed code has the same network and filesystem access as the
host process.
- Network access: allowed (host-local cannot restrict)
- Filesystem access: none requested
- Environment variables: none exposed
- 30-second timeout
- 1 MB stdout/stderr limits
Sourcepub fn strict_js() -> SandboxPolicy
pub fn strict_js() -> SandboxPolicy
Strict policy for embedded JavaScript execution.
Same defaults as Rust but with a shorter 5-second timeout, appropriate for lightweight transforms and scripting.
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§fn default() -> SandboxPolicy
fn default() -> SandboxPolicy
Sensible defaults: no network, no filesystem, no env vars, 30s timeout, 1 MB limits.