Sha256: 382bd01f2e9106eabee9465a842ad0c598d86cf21d6aae0897545042e507e94d
Contents?: true
Size: 1.46 KB
Versions: 3
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) Immunio::Utils.alias_method_chain base.singleton_class, :eval, :immunio end def self.included(base) Immunio::Utils.alias_method_chain base, :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 = Immunio::Context.context() Immunio.run_hook! "eval", "eval", parameters: args, context_key: loose_context, stack: 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 Immunio::Plugin.load 'Kernel (Eval)', feature: 'eval' do |plugin| Kernel.send :include, Immunio::KernelEvalHook Kernel.extend Immunio::KernelEvalHook plugin.loaded! RUBY_VERSION end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
immunio-1.1.6 | lib/immunio/plugins/eval.rb |
immunio-1.1.5 | lib/immunio/plugins/eval.rb |
immunio-1.1.2 | lib/immunio/plugins/eval.rb |