Sha256: cf112c17b67cd1d301caa85d44f53f42bd7495b65415524de7c9fc0d1117ecb0
Contents?: true
Size: 1.98 KB
Versions: 5
Compression:
Stored size: 1.98 KB
Contents
require_relative '../context' # We use DebugInspector to execute eval() in the callers frame. require 'binding_of_caller' module Immunio module KernelEvalHook extend ActiveSupport::Concern def self.extended(base) base.singleton_class.alias_method_chain :eval, :immunio end def self.included(base) base.alias_method_chain :eval, :immunio end protected def eval_with_immunio(*args) Immunio.logger.debug {"Eval_with_immunio with args: #{args}"} Request.time "plugin", "#{Module.nesting[0]}::#{__method__}" do strict_context, loose_context, stack, loose_stack = Immunio::Context.context() Immunio.run_hook! "eval", "eval", parameters: args, context_key: loose_context, stack: loose_stack Request.pause "plugin", "#{Module.nesting[0]}::#{__method__}" do if args.length == 1 then # eval call did not include a binding, so we eval it in the caller's binding # NOTE: the 7 here is the number of frames above us the caller was. Changing # the call stack will break this... rval = eval_without_immunio(args[0], binding.of_caller(7)) # XXX We can and should log here, but it breaks a ruby test (atom_feed_helper) #Immunio.logger.debug {"Eval_without_immunio (binding 7) returned: #{rval.inspect}\nEval stack was: #{stack}"} else # eval call included a binding, so we still eval in the binding rval = eval_without_immunio(*args) # XXX We can and should log here, but it breaks a ruby test (atom_feed_helper) #Immunio.logger.debug {"Eval_without_immunio returned: #{rval.inspect}"} end rval end end end end end if Immunio::agent.plugin_enabled?("eval") then Kernel.send :include, Immunio::KernelEvalHook Kernel.extend Immunio::KernelEvalHook Immunio.logger.debug "Eval: All hooks installed." end
Version data entries
5 entries across 5 versions & 1 rubygems