Cordon::Policy
Inherits JSON::Serializable < Reference < Object
Describes what a sandboxed process is permitted to access. Platform runners translate this into their native policy format — an SBPL profile on macOS, a bwrap flag list on Linux.
Can be constructed programmatically or deserialised from JSON:
Programmatic
policy = Cordon::Policy.build do |p| p.read_only "/usr/share/myapp" p.read_write "/tmp/workspace" p.tmpfs "/tmp" p.allow_network = false p.working_dir = "/tmp/workspace" p.env["MYAPP_ENV"] = "production" end
From a JSON file
policy = Cordon::Policy.from_json(File.read("policy.json"))
Round-trip to JSON
puts policy.to_json
Constructors
Instance methods
Whether outbound network access is permitted. Default: false.
Explicit environment variables to expose inside the sandbox. On bwrap the environment is cleared first; a safe default set (PATH, TERM, LANG, LC_ALL) is passed through before these. On macOS the full parent environment is inherited by sandbox-exec.
Explicit environment variables to expose inside the sandbox. On bwrap the environment is cleared first; a safe default set (PATH, TERM, LANG, LC_ALL) is passed through before these. On macOS the full parent environment is inherited by sandbox-exec.
Returns a new Policy that is the union of self and other.
Merge rules:
- Arrays (paths, unset_env): union, duplicates removed, order preserved.
- allow_network: true if either policy allows it (OR semantics).
- new_session: true if either policy requires it (OR semantics — safer).
- working_dir: other wins if set, otherwise self is kept.
- env: merged; other wins on key collision.
Start a new session (setsid). Prevents TTY escape attacks. Default: true.
Paths the sandboxed process may read but not write.
Paths the sandboxed process may read and write.
Paths to back with in-memory scratch space (tmpfs on Linux). On macOS, sandbox-exec cannot mount tmpfs — these paths receive RW access to the existing filesystem location instead. Pass a pre-created Dir.tempdir value for true scratch isolation.
Paths to back with in-memory scratch space (tmpfs on Linux). On macOS, sandbox-exec cannot mount tmpfs — these paths receive RW access to the existing filesystem location instead. Pass a pre-created Dir.tempdir value for true scratch isolation.
Environment variables to explicitly remove (bwrap only).
Working directory inside the sandbox. Must fall within one of the accessible path lists.