Skip to content

Not understanding why this is not working #34

@vizcay

Description

@vizcay
require 'shikashi'

class EvalContext
  def get_binding
    binding
  end

  def a_method
    puts 'test ok'
  end
end

eval_context = EvalContext.new
eval_context.get_binding.eval('a_method') # => test ok

sandbox = Shikashi::Sandbox.new
privileges = Shikashi::Privileges.new
privileges.allow_method(:a_method)

sandbox.run('a_method', privileges: privileges, binding: eval_context.get_binding)
# => in 'handle_method': Cannot invoke method method_missing on object of class BasicObject (SecurityError)
sandbox.run('a_method', privileges: privileges, base_namespace: eval_context)
# => in `rescue in packet': SyntaxError (SyntaxError)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions