Skip to content

Instantly share code, notes, and snippets.

Created October 3, 2013 17:33
Show Gist options
  • Save anonymous/6813761 to your computer and use it in GitHub Desktop.
Save anonymous/6813761 to your computer and use it in GitHub Desktop.
it won't work, security error both with module and class, what's wrong?
#!/usr/bin/env ruby
require "rubygems"
require "shikashi"
include Shikashi
s = Sandbox.new
priv = Privileges.new
# allow execution of foo, print, puts in this object
priv.object(self).allow :foo, :print, :puts, :new
#inside the sandbox, only can use method foo on main and method times on instances of Fixnum
code = <<-EOS
# class MP
class MP
def calc(a,b)
a + b
end
def test(a)
c = calc(10,20)
puts "inside test "
if (a)
system('ls -l') # denied
end
end
end
#include AtlasMP
#test
AtlasMP.new.test
EOS
s.run(code, priv)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment