Class: Contrast::Extension::Assess::RegexpPropagator
- Defined in:
- lib/contrast/extension/assess/regexp.rb,
ext/cs__assess_regexp/cs__assess_regexp.c
Overview
This Class provides us with a way to invoke Regexp propagation for those methods which are too complex to fit into one of the standard Contrast::Agent::Assess::Policy::Propagator molds without cluttering up the Regexp Class or exposing our methods there.
Class Method Summary collapse
Methods included from Components::Logger::InstanceMethods
Methods included from Components::Scope::InstanceMethods
contrast_enter_method_scopes!, contrast_exit_method_scopes!, with_app_scope, with_contrast_scope, with_deserialization_scope, with_split_scope
Class Method Details
.track_equal_squiggle(info_hash) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/contrast/extension/assess/regexp.rb', line 37 def track_equal_squiggle info_hash return unless ::Contrast::ASSESS.enabled? # Because we have a special case for this propagation, # it falls out of regular scoping. As such, any patch to the `=~` method # that goes through normal channels, like that for the redos rule, # will force this to be in a scope of 1 (instead of the normal 0). # As such, a scope of 1 here indicates that, # so we know that we're in the top level call for this method. # normal patch [-alias-]> special case patch [-alias-]> original method # TODO: RUBY-686 return if scope_for_current_ec.instance_variable_get(:@contrast_scope) > 1 target = info_hash[:back_ref] with_contrast_scope do return unless (result = info_hash[:result]) return unless (string = info_hash[:string]) return unless (properties = Contrast::Agent::Assess::Tracker.properties!(target)) properties.splat_from(string, target) event_data = Contrast::Agent::Assess::Events::EventData.new(REGEXP_EQUAL_SQUIGGLE_NODE, target, self, result, [string]) properties.build_event(event_data) end rescue Exception => e # rubocop:disable Lint/RescueException logger.error('Unable to propagate during Regexp#=~', e) end |