Class: Contrast::Agent::Assess::Policy::Propagator::Keep

Inherits:
Base
  • Object
show all
Defined in:
lib/contrast/agent/assess/policy/propagator/keep.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, tracked_value?

Class Method Details

.propagate(propagation_node, preshift_or_object, target) ⇒ Object

Keep means the tags just pass from the source to the target as is.

governing the propagation. source object passed if track_original_object flag is active.

Parameters:



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

def propagate propagation_node, preshift_or_object, target
  return unless (properties = Contrast::Agent::Assess::Tracker.properties!(target))

  source = if propagation_node.use_original_object?
             # for now this is used with string based object and with methods not mutating
             # original object, so we will always return 'O' key which is the object itself.
             # Because preshift is disabled for this methods we use it's parameter to pass
             # in the original object, preshift = object. To see list of methods in which
             # this is used:
             # Contrast::Utils::MethodCheck::ORIGINAL_OBJECT_METHODS
             preshift_or_object
           else
             find_source(propagation_node.sources[0], preshift_or_object)
           end
  properties.copy_from(source, target, 0, propagation_node.untags)
end