Module: Threatstack::Instrumentation::Frameworks::TSKernel
- Defined in:
- lib/instrumentation/frameworks/kernel.rb
Constant Summary collapse
- METHOD_NAMES =
methods to wrap
['exec', 'system', '`'].freeze
- @@logger =
Threatstack::Utils::TSLogger.create 'KernelINST'
Class Method Summary collapse
Class Method Details
.wrap_methods ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/instrumentation/frameworks/kernel.rb', line 16 def self.wrap_methods # executed every time a wrapped method is called on_method_call = Proc.new do |params| module_name, method_name, file_path, line_num, args = Threatstack::Instrumentation.extract_instrumentation_params params # special case for ` method emulation if method_name == '`' && !file_path.nil? && file_path =~ /.*\/kernel\/agnostics\.rb$/ called_by = params[:caller_loc][1] file_path = called_by ? called_by.absolute_path : nil end # create and queue the event Threatstack::Instrumentation.create_instrumentation_event(module_name, method_name, file_path, line_num, args) end @@logger.info "Instrumenting Kernel methods: #{METHOD_NAMES}" instrumenter = Threatstack::Instrumentation::Instrumenter.instance METHOD_NAMES.each do |method_name| instrumenter.wrap_class_method(Kernel, method_name, &on_method_call) instrumenter.wrap_instance_method(Kernel, method_name, &on_method_call) end end |