gleamunison/sandbox_policy
Types
pub type BoundaryRefusal {
MissingExternalExecutor
DirectHostFfiDenied
InvalidResourceBudget
}
Constructors
-
MissingExternalExecutor -
DirectHostFfiDenied -
InvalidResourceBudget
pub type ExecutionProfile {
Local
AuthenticatedRemote
UntrustedExecution
}
Constructors
-
Local -
AuthenticatedRemote -
UntrustedExecution
pub type ExternalExecutor {
ExternalExecutor(
name: String,
launcher: fn(String, ResourceBudget) -> Result(String, String),
)
}
Constructors
-
ExternalExecutor( name: String, launcher: fn(String, ResourceBudget) -> Result(String, String), )
pub type ResourceBudget {
ResourceBudget(
deadline_ms: Int,
max_processes: Int,
max_memory_bytes: Int,
max_reductions: Int,
max_concurrency: Int,
)
}
Constructors
-
ResourceBudget( deadline_ms: Int, max_processes: Int, max_memory_bytes: Int, max_reductions: Int, max_concurrency: Int, )
pub type SandboxPolicy {
SandboxPolicy(
profile: ExecutionProfile,
budget: ResourceBudget,
abilities: capability.Policy,
direct_host_ffi: Bool,
external_executor: option.Option(ExternalExecutor),
)
}
Constructors
-
SandboxPolicy( profile: ExecutionProfile, budget: ResourceBudget, abilities: capability.Policy, direct_host_ffi: Bool, external_executor: option.Option(ExternalExecutor), )
Values
pub fn admit(
policy: SandboxPolicy,
) -> Result(SandboxPolicy, BoundaryRefusal)
pub fn admit_profile(profile: String) -> Result(Nil, String)
Transport-facing admission. An Erlang route knows the deployment profile name from the environment, not a Gleam record, so this builds the policy for that name and admits it. Ok means the profile may serve untrusted work; Error carries the refusal name.
This is the enforcement point the README claims: the untrusted-execution profile refuses until a real external executor exists, and it refuses direct host FFI by construction.
pub fn default_budget() -> ResourceBudget
pub fn denies_untrusted_execution(profile: String) -> Bool
pub fn execute(
policy: SandboxPolicy,
input: String,
) -> Result(String, String)
pub fn local(abilities: capability.Policy) -> SandboxPolicy
pub fn refusal_name(refusal: BoundaryRefusal) -> String
pub fn untrusted(
abilities: capability.Policy,
external_executor: option.Option(ExternalExecutor),
) -> SandboxPolicy