Class: Contrast::Agent::Protect::Rule::InputClassification::EncodingRates

Inherits:
Rates
  • Object
show all
Defined in:
lib/contrast/agent/protect/rule/input_classification/encoding_rates.rb

Overview

This class will hold match information when input classification is being saved in LRU cache.

Constant Summary

Constants inherited from Rates

Rates::FIELD_NAME, Rates::TEST_NAME

Instance Attribute Summary collapse

Attributes inherited from Rates

#input_type, #rule_id

Instance Method Summary collapse

Methods inherited from Rates

#empty?

Constructor Details

#initialize(input_type) ⇒ EncodingRates

Returns a new instance of EncodingRates.



18
19
20
21
22
# File 'lib/contrast/agent/protect/rule/input_classification/encoding_rates.rb', line 18

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

Instance Attribute Details

#base64_matchesInteger (readonly)

Returns:

  • (Integer)


14
15
16
# File 'lib/contrast/agent/protect/rule/input_classification/encoding_rates.rb', line 14

def base64_matches
  @base64_matches
end

#base64_mismatchesInteger (readonly)

Returns:

  • (Integer)


16
17
18
# File 'lib/contrast/agent/protect/rule/input_classification/encoding_rates.rb', line 16

def base64_mismatches
  @base64_mismatches
end

Instance Method Details

#increase_match_base64Object

Increase the match count for the given rule_id and input.



25
26
27
# File 'lib/contrast/agent/protect/rule/input_classification/encoding_rates.rb', line 25

def increase_match_base64
  @base64_matches += 1
end

#increase_mismatch_base64Object



29
30
31
# File 'lib/contrast/agent/protect/rule/input_classification/encoding_rates.rb', line 29

def increase_mismatch_base64
  @base64_mismatches += 1
end

#to_fieldsHash

Returns Agent Telemetry reportable fields.

Returns:



36
37
38
39
40
41
# File 'lib/contrast/agent/protect/rule/input_classification/encoding_rates.rb', line 36

def to_fields
  {
      "#{ to_field_title }.input_base64_matches" => base64_matches,
      "#{ to_field_title }.input_base64_mismatches" => base64_mismatches
  }
end