Skip to content

Executor

Command executors run external processes with controlled environments. Two executor types are available: native OS processes and Docker containers.

KindDescription
exec.nativeExecute commands directly on the host OS
exec.dockerExecute commands inside Docker containers

Runs commands directly on the host operating system.

- name: shell
kind: exec.native
default_work_dir: /app
default_env:
PATH: /usr/local/bin:/usr/bin:/bin
LANG: en_US.UTF-8
command_whitelist:
- git status
- git diff
- npm run build
FieldTypeDefaultDescription
default_work_dirstring-Working directory for all commands
default_envmap-Environment variables (merged with per-command env)
command_whiteliststring[]-If set, only these exact commands are allowed
Native executors use a clean environment by default. Only explicitly configured environment variables are passed to child processes.

Runs commands inside isolated Docker containers.

- name: sandbox
kind: exec.docker
image: python:3.11-slim
default_work_dir: /workspace
network_mode: none
memory_limit: 536870912
cpu_quota: 50000
auto_remove: true
read_only_rootfs: true
no_new_privileges: true
cap_drop:
- ALL
tmpfs:
/tmp: rw,noexec,nosuid,size=64m
volumes:
- /app/data:/workspace/data:ro
FieldTypeDefaultDescription
imagestringrequiredDocker image to use
hoststringunix socketDocker daemon URL
default_work_dirstring-Working directory inside container
default_envmap-Environment variables
command_whiteliststring[]-Allowed commands (exact match)
network_modestringbridgeNetwork mode: host, bridge, none
volumesstring[]-Volume mounts: host:container[:ro]
userstring-User to run as inside container
memory_limitint0Memory limit in bytes (0 = unlimited)
cpu_quotaint0CPU quota (100000 = 1 CPU, 0 = unlimited)
auto_removeboolfalseRemove container after exit
read_only_rootfsboolfalseMake root filesystem read-only
no_new_privilegesboolfalsePrevent privilege escalation
cap_dropstring[]-Linux capabilities to drop
cap_addstring[]-Linux capabilities to add
pids_limitint0Max processes (0 = unlimited)
tmpfsmap-Tmpfs mounts for writable paths

Both executor types support command whitelisting. When configured, only exact command matches are allowed:

command_whitelist:
- ls -la
- cat /etc/passwd

Commands not in the whitelist are rejected with an error.

The Exec Module provides command execution:

local exec = require("exec")
local executor, err = exec.get("app:shell")
if err then return nil, err end
local proc = executor:exec("git status", {
work_dir = "/app/repo"
})
local stdout = proc:stdout_stream()
proc:start()
local output = stdout:read()
proc:wait()
stdout:close()
executor:release()