tario / shikashi

shikashi is a ruby sandbox that permits the execution of "unprivileged" scripts by defining the permitted methods and constants the scripts can invoke with a white list logic

Home Page:http://tario.github.com/shikashi/doc/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Missing defined methods in ruby1.9

tario opened this issue · comments

----------------example.rb-----------------
require "rubygems"
require "shikashi"

include Shikashi

s = Sandbox.new
priv = Privileges.new

allow execution of print

priv.allow_method :print

priv.allow_method "core#define_method".to_sym
priv.allow_method :instance_method

allow definition of classes

priv.allow_class_definitions

inside the sandbox, only can use method foo on main and method times on instances of Fixnum

s.run(priv, '
class X
def foo
print "X#foo\n"
end

end
')

print X.shadow.instance_method(:foo),"\n"

$ ruby1.8 example6.rb

<UnboundMethod: #Class:0x7fa4e82e80d0#foo>

$ ruby1.9 example6.rb
example6.rb:28:in instance_method': undefined methodfoo' for class X' (NameError) from example6.rb:28:in

'

Invalid, there is support for Ruby 1.9 in the latest version