Class: Contrast::Agent::Assess::Policy::Propagator::MatchData

Inherits:
Base
  • Object
show all
Defined in:
lib/contrast/agent/assess/policy/propagator/match_data.rb

Overview

Propagation that results in all the tags of the source being applied to the target exactly as is. The target’s preexisting tags are unaffected beyond any merging of overlapping tags.

Class Method Summary collapse

Methods inherited from Base

find_source, propagate, tracked_value?

Class Method Details

.captures_tagger(propagation_node, preshift, ret, _block) ⇒ Object



36
37
38
39
40
41
42
43
44
# File 'lib/contrast/agent/assess/policy/propagator/match_data.rb', line 36

def captures_tagger propagation_node, preshift, ret, _block
  ret.each_with_index do |return_value, index|
    next unless return_value

    targetted_index = index + 1
    square_bracket_single(targetted_index, preshift, return_value, propagation_node)
  end
  ret
end

.square_bracket_tagger(propagation_node, preshift, ret, _block) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/contrast/agent/assess/policy/propagator/match_data.rb', line 14

def square_bracket_tagger propagation_node, preshift, ret, _block
  case ret
  when Array
    ret.each_with_index do |return_value, index|
      next unless return_value

      target_matchdata_index = if preshift.args[0].is_a?(Range)
                                 arg_range = preshift.args[0]
                                 arg_range.to_a.empty? ? index + 1 : arg_range.to_a[index]
                               else
                                 preshift.args[index]
                               end
      square_bracket_single(target_matchdata_index, preshift, return_value, propagation_node)
    end
  when String
    target_matchdata_index = preshift.args[0]
    square_bracket_single(target_matchdata_index, preshift, ret, propagation_node)
  end

  ret
end

.to_a_tagger(propagation_node, preshift, ret, _block) ⇒ Object



46
47
48
49
50
51
52
53
# File 'lib/contrast/agent/assess/policy/propagator/match_data.rb', line 46

def to_a_tagger propagation_node, preshift, ret, _block
  ret.each_with_index do |return_value, index|
    next unless return_value

    square_bracket_single(index, preshift, return_value, propagation_node)
  end
  ret
end

.values_at_tagger(propagation_node, preshift, ret, _block) ⇒ Object



55
56
57
58
59
60
61
62
63
# File 'lib/contrast/agent/assess/policy/propagator/match_data.rb', line 55

def values_at_tagger propagation_node, preshift, ret, _block
  ret.each_with_index do |return_value, return_index|
    next unless return_value

    original_group_arg_index = preshift.args[return_index]
    square_bracket_single(original_group_arg_index, preshift, return_value, propagation_node)
  end
  ret
end