Sha256: 96180d73132243bd9db50955e09d3d8b5dd00a7454641888f730d47dceb99bb6

Contents?: true

Size: 1.36 KB

Versions: 2

Compression:

Stored size: 1.36 KB

Contents

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

require 'contrast/agent/assess/policy/source_validation/cross_site_validator'

module Contrast
  module Agent
    module Assess
      module Policy
        # Some of our sources require validation to prevent them from applying
        # certain tags in a given context. This provides a single place from
        # which those validations can be called.
        module SourceValidation
          VALIDATORS = [
            Contrast::Agent::Assess::Policy::SourceValidation::CrossSiteValidator
          ].cs__freeze

          # Determines if the conditions in which this source was called are
          # valid and should result in the application of a tag
          #
          # @param tag [String] the tag which the Source is attempting to apply
          # @param source_type [String] the type of the source
          # @param source_name [String] the name of the source
          # @return [Boolean] if the conditions are valid for the application
          #   of a tag
          def self.valid? tag, source_type, source_name
            VALIDATORS.each do |validator|
              return false unless validator.valid?(tag, source_type, source_name)
            end
            true
          end
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
contrast-agent-4.6.0 lib/contrast/agent/assess/policy/source_validation/source_validation.rb
contrast-agent-4.5.0 lib/contrast/agent/assess/policy/source_validation/source_validation.rb