Sha256: 23e28ec9c4ec0c2927c38f1e2351f83f1106cec7603bfee78e3f54b1abbfb863

Contents?: true

Size: 1.4 KB

Versions: 24

Compression:

Stored size: 1.4 KB

Contents

# Copyright (c) 2022 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 in reverse of how they are in the source. The
          # target's preexisting tags are unaffected beyond any merging of
          # overlapping tags.
          class Reverse < Contrast::Agent::Assess::Policy::Propagator::Base
            class << self
              def propagate propagation_node, preshift, target
                return unless (properties = Contrast::Agent::Assess::Tracker.properties!(target))

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

                length = target.length
                properties.tag_keys.each do |key|
                  tags = properties.fetch_tag(key)
                  tags.each do |tag|
                    new_end = length - tag.start_idx
                    new_start = new_end - tag.length
                    tag.repurpose(new_start, new_end)
                  end
                end

                properties.cleanup_tags
              end
            end
          end
        end
      end
    end
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
contrast-agent-6.11.0 lib/contrast/agent/assess/policy/propagator/reverse.rb
contrast-agent-6.10.0 lib/contrast/agent/assess/policy/propagator/reverse.rb
contrast-agent-6.9.0 lib/contrast/agent/assess/policy/propagator/reverse.rb
contrast-agent-6.8.0 lib/contrast/agent/assess/policy/propagator/reverse.rb
contrast-agent-6.7.0 lib/contrast/agent/assess/policy/propagator/reverse.rb
contrast-agent-6.6.5 lib/contrast/agent/assess/policy/propagator/reverse.rb
contrast-agent-6.6.4 lib/contrast/agent/assess/policy/propagator/reverse.rb
contrast-agent-6.6.3 lib/contrast/agent/assess/policy/propagator/reverse.rb
contrast-agent-6.6.2 lib/contrast/agent/assess/policy/propagator/reverse.rb
contrast-agent-6.6.1 lib/contrast/agent/assess/policy/propagator/reverse.rb
contrast-agent-6.6.0 lib/contrast/agent/assess/policy/propagator/reverse.rb
contrast-agent-6.5.1 lib/contrast/agent/assess/policy/propagator/reverse.rb
contrast-agent-6.5.0 lib/contrast/agent/assess/policy/propagator/reverse.rb
contrast-agent-6.4.0 lib/contrast/agent/assess/policy/propagator/reverse.rb
contrast-agent-6.3.0 lib/contrast/agent/assess/policy/propagator/reverse.rb
contrast-agent-6.2.0 lib/contrast/agent/assess/policy/propagator/reverse.rb
contrast-agent-6.1.2 lib/contrast/agent/assess/policy/propagator/reverse.rb
contrast-agent-6.1.1 lib/contrast/agent/assess/policy/propagator/reverse.rb
contrast-agent-6.1.0 lib/contrast/agent/assess/policy/propagator/reverse.rb
contrast-agent-6.0.0 lib/contrast/agent/assess/policy/propagator/reverse.rb