Sha256: f96890c3a2aed78eded76b28b547de4037137b52068364acf99514ad7ba72840

Contents?: true

Size: 1.44 KB

Versions: 8

Compression:

Stored size: 1.44 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/protect/rule/input_classification/rates'

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 EncodingRates < Contrast::Agent::Protect::Rule::InputClassification::Rates
            # @return [Integer]
            attr_reader :base64_matches
            # @return [Integer]
            attr_reader :base64_mismatches

            def initialize input_type
              super(nil, input_type)
              @base64_matches = 0
              @base64_mismatches = 0
            end

            # Increase the match count for the given rule_id and input.
            def increase_match_base64
              @base64_matches += 1
            end

            def increase_mismatch_base64
              @base64_mismatches += 1
            end

            # Returns Agent Telemetry reportable fields.
            #
            # @return [Hash]
            def to_fields
              {
                  "#{ to_field_title }.input_base64_matches" => base64_matches,
                  "#{ to_field_title }.input_base64_mismatches" => base64_mismatches
              }
            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/encoding_rates.rb
contrast-agent-7.6.0 lib/contrast/agent/protect/rule/input_classification/encoding_rates.rb
contrast-agent-7.5.0 lib/contrast/agent/protect/rule/input_classification/encoding_rates.rb
contrast-agent-7.4.1 lib/contrast/agent/protect/rule/input_classification/encoding_rates.rb
contrast-agent-7.4.0 lib/contrast/agent/protect/rule/input_classification/encoding_rates.rb
contrast-agent-7.3.2 lib/contrast/agent/protect/rule/input_classification/encoding_rates.rb
contrast-agent-7.3.1 lib/contrast/agent/protect/rule/input_classification/encoding_rates.rb
contrast-agent-7.3.0 lib/contrast/agent/protect/rule/input_classification/encoding_rates.rb