Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MaskedDirs ¶ added in v0.107.16
func MaskedDirs() []string
MaskedDirs are the credential directories hidden from sandboxed commands.
func ProtectedPaths ¶ added in v0.107.16
ProtectedPaths are the paths under a workspace that a later, unsandboxed session or the user's own git trusts without asking: project instructions and prompts, and the repository's hooks and configuration (which can name a hooks directory, an fsmonitor or a pager to run). Paths that do not exist yet are listed too; Seatbelt keeps them from being created.
func RootFromEnv ¶
func RootFromEnv() string
Types ¶
type Capability ¶ added in v0.107.16
type Capability struct {
Supported bool `json:"supported"`
Mechanism string `json:"mechanism"`
Platform string `json:"platform"`
NetworkControl bool `json:"network_control"`
ReadMasking bool `json:"read_masking"`
// PathProtection reports whether the protected workspace paths (git hooks
// and config, agent settings) stay read-only inside a writable root.
PathProtection bool `json:"path_protection"`
Reason string `json:"reason,omitempty"`
}
Capability reports whether this machine can confine a run's commands.
func Probe ¶ added in v0.107.16
func Probe() Capability
Probe checks the platform mechanism once per process by running a trivial confined command, so a binary that exists but cannot start (no user namespaces in a container) reports unsupported instead of failing later.
type Denial ¶ added in v0.107.21
type Denial struct {
// Kind is "write" (a write outside the writable roots), "protected" (a
// protected or configured read-only path), "masked" (a hidden credential
// directory) or "network" (network access is off for the run).
Kind string `json:"kind"`
// Path is the path the denial names, when there is one.
Path string `json:"path,omitempty"`
// SuggestedRoot is a directory the user could add as a writable workspace
// root so the command can write Path. It is set only for a write the
// command itself named (its text contains the path), so output a command
// prints cannot steer the proposal, and never for a directory that holds
// the home directory, a credential directory or a system top-level
// directory.
SuggestedRoot string `json:"suggested_root,omitempty"`
}
Denial explains why a sandboxed command most likely failed. It is a hint for the model and the client, recognized from the command's output; nothing is granted from it.
type Policy ¶
type Policy struct {
Mode string
Backend string
Root string
Network bool
Writable []string
ReadOnly []string
// Masked directories are neither readable nor writable inside the sandbox
// (credentials, the backend's own data). A workspace root inside one of them
// stays usable; a root that encloses one is refused.
Masked []string
// Protected paths stay readable but not writable, even inside a writable
// root: project instructions and hooks that a later, unsandboxed session
// would trust.
Protected []string
// EnvKeep lists variable names (globs allowed) a sandboxed command still
// inherits although they look like credentials (FilterEnv).
EnvKeep []string
}
func ForRun ¶ added in v0.107.16
func ForRun(base *Policy, req RunRequest) (*Policy, error)
ForRun builds the policy for a run that asked for the workspace sandbox. A configured policy (base) is only ever tightened: its roots stay as they are, network stays off when either side turns it off, and the masks and protected paths are added. Without a configured policy the run's roots are the grants. The result fails closed: when the machine cannot confine commands an error is returned instead of a policy.
func FromContext ¶
func (*Policy) ExplainFailure ¶ added in v0.107.21
ExplainFailure recognizes a sandbox denial in the output of a command that exited with exitCode under p. It returns nil when the command succeeded, could not be found, or failed for a reason the sandbox does not explain, such as a permission error inside a writable root.
type RunRequest ¶ added in v0.107.16
type RunRequest struct {
Root string
// Writable lists the run's other writable workspace roots.
Writable []string
Network bool
// Masked and Protected extend the defaults (MaskedDirs, ProtectedPaths).
Masked []string
Protected []string
// EnvKeep extends the policy's EnvKeep.
EnvKeep []string
}
RunRequest is a run's request to confine its commands to the workspace.