Sha256: 10d41473acf1f944792dea49bd50a0689f0ff042b5054e23472b2d1d65811c3a

Contents?: true

Size: 1.5 KB

Versions: 4

Compression:

Stored size: 1.5 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 Reporting
      module Settings
        # Base class to represent common exclusions fields.
        class ExclusionBase
          BASE_ATTRIBUTES = %i[name modes assess_rules protect_rules].cs__freeze

          # @return name [String]
          attr_accessor :name
          # @return modes [Array<String>]
          attr_accessor :modes
          # @return assess_rules [Array<String>]
          attr_accessor :assess_rules
          # @return protect_rules [Array<String>]
          attr_accessor :protect_rules

          def initialize
            @modes = []
            @assess_rules = []
            @protect_rules = []
          end

          # @return [Boolean] does this exclusion apply to Assess or not
          def assess
            @_assess = modes&.include?('assess') if @_assess.nil?
            @_assess
          end

          # @return [Boolean] does this exclusion apply to Protect or not
          def protect
            @_protect = modes&.include?('defend') if @_protect.nil?
            @_protect
          end

          def to_controlled_hash
            {
                name: name, # rubocop:disable Security/Module/Name
                modes: modes,
                assessRules: assess_rules,
                protectRules: protect_rules
            }
          end
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
contrast-agent-6.11.0 lib/contrast/agent/reporting/settings/exclusion_base.rb
contrast-agent-6.10.0 lib/contrast/agent/reporting/settings/exclusion_base.rb
contrast-agent-6.9.0 lib/contrast/agent/reporting/settings/exclusion_base.rb
contrast-agent-6.8.0 lib/contrast/agent/reporting/settings/exclusion_base.rb