Yeesh.Sandbox (Yeesh v0.8.3)

View Source

Dune-powered sandboxed Elixir evaluation.

Wraps Dune.Session for safe, stateful Elixir code evaluation. Variables persist across inputs within a session.

Configuration

Sandbox options can be passed via :sandbox_opts:

  • :timeout - evaluation timeout in ms (default: 5000)
  • :max_reductions - max reductions (default: 50_000)
  • :max_heap_size - max heap size in words (default: 1_000_000)
  • :allowlist - custom Dune allowlist module (default: Dune.Allowlist.Default)

Summary

Functions

Evaluates Elixir code in the sandbox.

Creates a new Dune session.

Types

dune_state()

@type dune_state() :: term()

Functions

eval(arg, code)

@spec eval(dune_state(), String.t()) ::
  {:ok, String.t(), String.t(), dune_state()}
  | {:error, String.t(), dune_state()}

Evaluates Elixir code in the sandbox.

Returns {:ok, inspected_result, stdio, updated_dune_state} or {:error, message, updated_dune_state}.

new_session(opts \\ [])

@spec new_session(keyword()) :: dune_state()

Creates a new Dune session.