Sha256: 9aff39313bf5531d6792292b7bab91fc13cd724acaf89fb09b42040de9c2fcb9

Contents?: true

Size: 1.88 KB

Versions: 2

Compression:

Stored size: 1.88 KB

Contents

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

require 'contrast/extension/module'
require 'contrast/utils/assess/event_limit_utils'

module Contrast
  module Agent
    module Assess
      module Policy
        module Propagator
          # Propagation that results in some complex or specific translation
          # of tags from the source to the target. Each node with the CUSTOM
          # action knows the class and method it should call to preform this
          # action.
          module Custom
            extend Contrast::Utils::Assess::EventLimitUtils

            class << self
              # @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 ret [Object] the return value of the method.
              # @param block [Proc] the block passed to the method.
              # @return [Object] the return value of the method.
              def propagate propagation_node, preshift, ret, block
                clazz = propagation_node.patch_class
                method = propagation_node.patch_method

                # We cannot flip the String to a Module at patcher creation time -
                # the Module may not exist yet. Instead, we have to defer until the
                # first time the patcher is used.
                if clazz.is_a?(String)
                  clazz = Object.cs__const_get(clazz)
                  propagation_node.patch_class = clazz
                end
                clazz.send(method, propagation_node, preshift, ret, block)
                increment_event_count(propagation_node)
              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/custom.rb
contrast-agent-7.6.0 lib/contrast/agent/assess/policy/propagator/custom.rb