为什么我在使用Shikashi Gem的情景中获得安全错误“无法访问常量哈希”?
include Shikashi
privileges = Privileges.new
privileges.instances_of(Hash).allow_all
Sandbox.new.run(privileges, "arguments=Hash.new;")
任何见解?我需要在Sandbox中运行一些ruby代码,看看它是否表现得很好。
答案 0 :(得分:2)
您需要允许脚本read the Hash
constant。您还需要允许calling the new
method on the Hash
object:
include Shikashi
privileges = Privileges.new
privileges.allow_const_read "Hash"
privileges.object(Hash).allow :new
privileges.instances_of(Hash).allow_all
Sandbox.new.run(privileges, "arguments=Hash.new;")