lib/contrast/agent/tracepoint_hook.rb in contrast-agent-4.10.0 vs lib/contrast/agent/tracepoint_hook.rb in contrast-agent-4.11.0

- old
+ new

@@ -25,26 +25,34 @@ instance_variable_defined?(:@require_hook) && @require_hook.disable end private + # Use the TracePoint from the :end event, meaning the completion of a definition of a Class or Module (or + # really the completion of that piece of a definition, as determined by an `end` statement since there could be + # definitions across multiple files) to carry out actions required on definition. This typically involves + # patching and usage analysis + # + # @param tracepoint_event [TracePoint] the TracePoint from the :end def process tracepoint_event with_contrast_scope do - logger.trace('Received TracePoint end event', module: tracepoint_event.self.to_s) - + # the Module or Class that was loaded during this event loaded_module = tracepoint_event.self + # the file being loaded that contained this definition path = tracepoint_event.path return if path&.include?('contrast') + logger.trace('Received TracePoint end event', module: loaded_module, path: path) + Contrast::Agent.framework_manager.register_late_framework(loaded_module) Contrast::Agent::Inventory::DependencyUsageAnalysis.instance.associate_file(path) if path Contrast::Agent::Patching::Policy::Patcher.patch_specific_module(loaded_module) if RUBY_VERSION < '2.6.0' # TODO: RUBY-714 remove guard w/ EOL of 2.5 Contrast::Agent::Assess::Policy::RewriterPatch.rewrite_interpolation(loaded_module) end Contrast::Agent::Assess::Policy::PolicyScanner.scan(tracepoint_event) rescue StandardError => e - logger.error('Unable to complete TracePoint analysis', e, module: loaded_module) + logger.error('Unable to complete TracePoint analysis', e, module: loaded_module, path: path) end end end end end