Skip to main content

SandboxPolicy

Struct SandboxPolicy 

Source
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: NetworkMode

Network 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: bool

Nothing 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: Layout

What the instance names a project’s directory: the configuration root guarded in cwd.

§deny_ipc_escapes: bool

Also 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: ReadScope

What may be read at all; deny_read and the engine’s credentials stay unreadable inside it.

§env: EnvScope

The 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

Source

pub fn strict( &self, readable: impl IntoIterator<Item = PathBuf>, tmpdir: Option<PathBuf>, ) -> Self

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

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SandboxPolicy

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for SandboxPolicy

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more