Shikashi: ArgumentError: Wrong number of arguments with sandboxed code

I have a problem with Shikashi when calling methods with more than one parameter:

class MyTest def self.think message end def self.say person,message end end include Shikashi privileges = Privileges.new privileges.allow_const_read "MyTest" privileges.object(MyTest).allow_all privileges.instances_of(MyTest).allow_all Sandbox.new.run(privileges, "MyTest.think('you')") Sandbox.new.run(privileges, "MyTest.say('you', 'hi there')") 

It works

 Sandbox.new.run(privileges, "MyTest.think('you')") 

Here I get an ArgumentError: wrong number of arguments (1 to 2)

 Sandbox.new.run(privileges, "MyTest.say('you', 'hi there')") 

When I call him outside the Sandbox, everything is fine.

What's wrong? I am using ruby-1.9.3-p194

+4
source share
2 answers

Update:

Bug fixed in version 0.5.2; upgrade to this, and everything should be fine.

Original answer:

There is an error in all versions of evalhook (which shikashi uses to evaluate the code) is greater than 0.3.1, where methods are called only with the first argument. For instance:

 Sandbox.new.run(privileges, "MyTest.think('you', 'hi there')") 

works just fine, ignoring the second argument.

Unfortunately, the way to configure dependencies, you need to switch to shikashi 0.3.1 to use evalhook 0.3.1, but at least for me, shikashi 0.3.1 is broken and cannot be installed. I think your options are:

  • Do not use shikashi,
  • Do not use methods with more than one argument in the sandbox,
  • Track and fix the error in evalhook,
  • Ask the developer to fix the error or
  • See if you can convince the new version of shikashi to work with evalhook 0.3.1.
+2
source

I am a shikashi developer and I just clicked a fixed version of the evalhook gem (v0.5.2, shikashi dependency). To update a gem:

 gem update evalhook 

And then he should work

+3
source

All Articles