0.0
No commit activity in last 3 years
No release in over 3 years
A mruby sandbox running in its own sub process and having only a single pipe in and out to communicate with the outside. Provides a rather safe environment to run untrusted code.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.8
~> 3.4
rspec-mocks-matchers-send_message
~> 0.2

Runtime

~> 2.4
 Project Readme

A mruby sandbox for ruby

A mruby sandbox whose job is to run untrusted ruby code in a safe environment. Untrusted code is loaded into an environment having no access to the outside world by default. Receivers can be registered so methods can be called on the outside of the sandbox.

The sandbox runs as a subprocess of a managing parent process. To be able to communicate with its parent the sandbox also loads a restricted IO library that only allows reading and writing through STDIN and STDOUT. Besides STDERR no further IO Endpoints are passed down by the parent. The IO library does not implement any operations accessing files on the system or the like.

A gem has not been published, yet.

Usage

The string given to MrubySandbox#evaluate is parsed and evaluated in the sandbox by mruby:

sandbox = MrubySandbox.new
sandbox.evaluate "8+45" # => 53
sandbox.evaluate "system 'rm -rf /'" # => NoMethodError

The environment built by previous evaluations is accessible by following evaluations:

sandbox = MrubySandbox.new
sandbox.evaluate <<-CODE
  def meth
    'result'
  end

  class Klass
    def meth
      'klass meth'
    end
  end
CODE

sandbox.evaluate 'meth' # => 'result'
sandbox.evaluate 'Klass.new.meth' # => 'klass meth'