pub struct SandboxPolicy {Show 17 fields
pub allow_read: Vec<PathBuf>,
pub deny_read: Vec<PathBuf>,
pub deny_read_exact: Vec<PathBuf>,
pub deny_write: Vec<String>,
pub network_mode: NetworkMode,
pub allowed_domains: Vec<String>,
pub egress_proxy: Option<EgressProxy>,
pub additional_writable: Vec<PathBuf>,
pub read_only_dirs: Vec<PathBuf>,
pub only_additional_writable: bool,
pub worktree_git: Option<WorktreeGit>,
pub state_root: Option<PathBuf>,
pub foreign_state_roots: Vec<PathBuf>,
pub layout: Layout,
pub deny_ipc_escapes: bool,
pub read: ReadScope,
pub env: EnvScope,
}Expand description
What to constrain. The kernel’s, not a backend’s.
Defaults bake in a deny-read list (~/.ssh, ~/.aws, …) so that a naive
Bash command does not dump credential files into the model’s transcript by
accident. Not every field lands cleanly on every backend; the ones that do
not are reported through Enforcement rather than ignored.
Fields§
§allow_read: Vec<PathBuf>Absolute paths the sandbox is allowed to read, on top of the
universal default (everything readable). An entry that is also in
deny_read is re-allowed; a parent directory, or a path below a
denied one, changes nothing.
deny_read: Vec<PathBuf>Absolute paths the sandbox is denied read access to. Defaults
include common credential stores (see default_deny_read).
deny_read_exact: Vec<PathBuf>Paths denied as named, under no allow_read: the backends deny each
path’s own spellings and do not follow the links inside it.
deny_write: Vec<String>Filename segments no command may write inside a writable root: a path is refused when a component under the root equals one or begins with it followed by a dot. macOS refuses new and existing paths alike; Linux can only mount over the entries that exist when the command starts.
network_mode: NetworkModeNetwork policy — see NetworkMode.
allowed_domains: Vec<String>Domains allowed to make outbound connections when network_mode is
NetworkMode::Allowlist. Ignored otherwise. What each backend makes
of it is under NetworkMode::Allowlist.
egress_proxy: Option<EgressProxy>The only place outbound connections may go under
NetworkMode::Proxy. Ignored otherwise.
additional_writable: Vec<PathBuf>Paths outside cwd this command may still write to.
Part of the policy rather than a separate argument because it answers the same question the rest of it does — what may be written — and a backend that received it separately could be handed a policy that looks complete and is not.
read_only_dirs: Vec<PathBuf>Directories no command writes in, nor moves aside, wherever they lie: the host’s skill directories and its own packages.
only_additional_writable: boolNothing is writable but additional_writable and /dev: not cwd,
not the state root’s working directories, not the per-user temporary
directory. For the engine’s own git, which reads the project and
writes only where its bookkeeping lives.
worktree_git: Option<WorktreeGit>Where a working directory that is a linked worktree commits to, as
the engine checked it when it made the worktree: its git directory is
guarded as <cwd>/.git is otherwise, and what of it is writable is
crate::paths::WorktreeGit::writable in additional_writable. The
backends never follow the worktree’s own links to find it, since a
command may have rewritten them.
state_root: Option<PathBuf>This instance’s global state root, whose configuration a command may
not rewrite. None protects no state root: the backends do not guess
$HOME/.agix, since a redirected instance whose sandbox protected it
would be guarding a file it does not use while leaving its real
settings.json writable. Every session’s policy names one
(SandboxSettings::policy).
foreign_state_roots: Vec<PathBuf>Other instances’ state roots on this machine
(crate::paths::known_state_roots): a command reads none of their
credentials, writes nothing in them and connects to no socket in them.
layout: LayoutWhat the instance names a project’s directory: the configuration
root guarded in cwd.
deny_ipc_escapes: boolAlso refuse the ways a command can have another process act for it
outside the sandbox: on macOS sending Apple events, opening apps and
URLs through LaunchServices, and writing preferences through
cfprefsd; on Linux the host’s IPC namespace and the session bus.
For an unattended session, where nobody approved the command.
read: ReadScopeWhat may be read at all; deny_read and the engine’s credentials
stay unreadable inside it.
env: EnvScopeThe environment the command starts from. The backend marks the
confined spec with it (ProcessSpec::env_scope); the process
provider applies it.
Implementations§
Source§impl SandboxPolicy
impl SandboxPolicy
Sourcepub fn strict(
&self,
readable: impl IntoIterator<Item = PathBuf>,
tmpdir: Option<PathBuf>,
) -> SandboxPolicy
pub fn strict( &self, readable: impl IntoIterator<Item = PathBuf>, tmpdir: Option<PathBuf>, ) -> SandboxPolicy
The policy for a command let through on its own word
(ExecProfile::Strict): no network, nothing writable but tmpdir,
nothing readable but readable and tmpdir, the minimal
environment, and the IPC routes out refused. What this policy keeps
from being read stays unreadable under the strict one.
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 more