Module: ERBPropagator

Defined in:
lib/contrast/extension/assess/erb.rb

Overview

This module is used to track propagation through ERB template rendering

Class Method Summary collapse

Class Method Details

.result_tagger(patcher, preshift, ret, _block) ⇒ Object

After ERB#result method is called we need to take the tags to the target and keep the propagation.

Parameters:

  • patcher (Contrast::Agent::Assess::Policy::PolicyNode)

    the node that governs this event

  • preshift (Contrast::Agent::Assess::Preshift)

    Saved state before the propagation

  • ret (the Return of the invoked method)
  • _block (&block, nil)

    block passed



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/contrast/extension/assess/erb.rb', line 14

def result_tagger patcher, preshift, ret, _block
  return unless preshift.args.length >= 1
  return unless (properties = Contrast::Agent::Assess::Tracker.properties!(ret))

  used_binding = preshift.args[0]
  binding_variable_set = used_binding.local_variables

  erb_pre_result = preshift.object.src
  parent_events = []
  binding_variable_set(binding_variable_set, used_binding, erb_pre_result, properties, parent_events, ret)
  properties.build_event(Contrast::Agent::Assess::Events::EventData.new(patcher,
                                                                        ret,
                                                                        preshift.object,
                                                                        ret,
                                                                        preshift.args), 1)
  properties.event.instance_variable_set(:@_parent_events, parent_events)

  ret
end