Sha256: 83671997acfca1dec8ee3d6b32aedd27a36751a5ef19082d71799227f8a4c9c6
Contents?: true
Size: 1.46 KB
Versions: 5
Compression:
Stored size: 1.46 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[1].nil? # 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... args[1] = binding.of_caller(7) end eval_without_immunio(*args) 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