Sha256: 1ece277b5de601dc382059874c4b7ac86db8cec96d2f711f50ed4d1efc6615d8

Contents?: true

Size: 1.46 KB

Versions: 8

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

require 'contrast/agent/reporting/input_analysis/input_type'
require 'contrast/utils/duck_utils'

module Contrast
  module Agent
    module Protect
      module Rule
        module InputClassification
          # This class will hold match information when input classification is being saved in LRU cache.
          class Rates
            # Titles:
            FIELD_NAME = 'ia'
            TEST_NAME = '_t'

            # @return [String]
            attr_reader :rule_id
            # @return [Symbol, nil]
            attr_reader :input_type

            def initialize rule_id, input_type
              @rule_id = rule_id if rule_id
              @input_type = input_type if Contrast::Agent::Reporting::InputType.to_a.include?(input_type)
            end

            def empty?
              Contrast::Utils::DuckUtils.empty_duck?(@input_type)
            end

            # Override this method to return the required Agent Telemetry fields.
            # @return [Hash]
            def to_fields
              {}
            end

            private

            # @return [String]
            def to_field_title
              if (ENV['CONTRAST_AGENT_TELEMETRY_TEST'] = '1')
                TEST_NAME
              else
                FIELD_NAME
              end
            end
          end
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
contrast-agent-7.6.1 lib/contrast/agent/protect/rule/input_classification/rates.rb
contrast-agent-7.6.0 lib/contrast/agent/protect/rule/input_classification/rates.rb
contrast-agent-7.5.0 lib/contrast/agent/protect/rule/input_classification/rates.rb
contrast-agent-7.4.1 lib/contrast/agent/protect/rule/input_classification/rates.rb
contrast-agent-7.4.0 lib/contrast/agent/protect/rule/input_classification/rates.rb
contrast-agent-7.3.2 lib/contrast/agent/protect/rule/input_classification/rates.rb
contrast-agent-7.3.1 lib/contrast/agent/protect/rule/input_classification/rates.rb
contrast-agent-7.3.0 lib/contrast/agent/protect/rule/input_classification/rates.rb