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

propagation action required by this method.

Parameters:

Returns:

  • (Object)

    the target with the tags applied



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

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

Handles the splatting of tags from the tracked inputs to the target.

Parameters:

  • tracked_inputs (Array<String>)

    storage for the inputs to act on later

  • target (Object)

    the object to which the source is being appended

Returns:

  • (Object)

    the target with the tags applied



41
42
43
44
45
46
47
48
49
50
51
# File 'lib/contrast/agent/assess/policy/propagator/splat.rb', line 41

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