Sha256: 446da9bf9bf322c4bb6b13729095e539cc4f4be4afa9f420365d3a175777d34e

Contents?: true

Size: 1.46 KB

Versions: 2

Compression:

Stored size: 1.46 KB

Contents

# Copyright (c) 2023 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
# frozen_string_literal: true

module Contrast
  module Agent
    module Assess
      module Policy
        module Propagator
          # Propagation that results in all the tags of the source being
          # applied to the target exactly as they are in the source. The
          # target's preexisting tags are all removed.
          class Replace < Contrast::Agent::Assess::Policy::Propagator::Base
            class << self
              # Replace means we're replacing the target w/ the source. Anything
              # on the source should be passed to the target.
              #
              # @param propagation_node [Contrast::Agent::Assess::Policy::PropagationNode] the node responsible for the
              # propagation action required by this method.
              # @param preshift [Object] pre call state of the things.
              # @param target [Object] the object to which the source is being appended
              def propagate propagation_node, preshift, target
                return unless (properties = Contrast::Agent::Assess::Tracker.properties!(target))

                source = find_source(propagation_node.sources[0], preshift)
                properties.clear_tags
                properties.copy_from(source, target, 0, propagation_node.untags)
              end
            end
          end
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
contrast-agent-7.6.1 lib/contrast/agent/assess/policy/propagator/replace.rb
contrast-agent-7.6.0 lib/contrast/agent/assess/policy/propagator/replace.rb