Only the files you grant
List what the command may read and write, and deny paths inside them. Everything else on the machine stays out of reach.
Filesystem policies
Give code your application did not write only the files, hosts, and time you choose. One gem, built on Microsoft's MXC, on Linux, macOS, and Windows.
class SkillSandbox < MXC::Sandbox
readable "app/skills"
writable "tmp/skills"
denied "app/skills/secrets"
directory "app/skills"
network allow: ["pypi.org"]
timeout 30
end
sandbox = SkillSandbox.new
result = sandbox.run("python3 build.py")
result.success? # => true
result.stdout # => "Built report.pdf\n"
sandbox = SkillSandbox.new
result = sandbox.run("pip index versions flask")
result.blocked # => ["telemetry.example.com:443"]
sandbox = SkillSandbox.new
sandbox.run("python3", "build.py") do |chunk|
print chunk.content
end
process = SkillSandbox.new.spawn("python3 -i -q")
process.write("print(6 * 7)\n")
process.close_write
process.each { |chunk| print chunk.content }
process.wait.success? # => true
SkillSandbox.new.supported? # => false
SkillSandbox.new.availability.remediation
# => "Install slirp4netns, iptables ..."