Class: Contrast::Agent::Assess::Policy::Propagator::Splat

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

Overview

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

Class Method Summary collapse

Methods inherited from Base

find_source, tracked_value?

Class Method Details

.propagate(propagation_node, preshift, target) ⇒ Object



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

def propagate propagation_node, preshift, target
  tracked_inputs = []

  propagation_node.sources.each do |source|
    case source
    when Contrast::Utils::ObjectShare::OBJECT_KEY
      tracked_inputs << preshift.object if Contrast::Agent::Assess::Tracker.tracked?(preshift.object)
    else
      check_for_buffer(tracked_inputs, preshift.args[source])
      find_argument_inputs(tracked_inputs, preshift.args[source])
    end
  end

  splat_tags(tracked_inputs, target)
  Contrast::Agent::Assess::Tracker.properties(target)&.cleanup_tags
end

.splat_tags(tracked_inputs, target) ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
# File 'lib/contrast/agent/assess/policy/propagator/splat.rb', line 31

def splat_tags tracked_inputs, target
  return if tracked_inputs.empty?
  return unless (properties = Contrast::Agent::Assess::Tracker.properties!(target))

  tracked_inputs.each do |input|
    input_properties = Contrast::Agent::Assess::Tracker.properties(input)
    next unless input_properties

    properties.splat_from(input, target)
  end
end