Class: Contrast::Agent::Protect::Rule::InputClassification::MatchRates
- Inherits:
-
Rates
- Object
- Rates
- Contrast::Agent::Protect::Rule::InputClassification::MatchRates
show all
- Defined in:
- lib/contrast/agent/protect/rule/input_classification/match_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
Constructor Details
#initialize(rule_id, input_type, score_level) ⇒ MatchRates
25
26
27
28
29
30
31
|
# File 'lib/contrast/agent/protect/rule/input_classification/match_rates.rb', line 25
def initialize rule_id, input_type, score_level
super(rule_id, input_type)
@input_matches = 0
@request_matches = 0
@input_mismatches = 0
@score_level = score_level if Contrast::Agent::Reporting::ScoreLevel.to_a.include?(score_level)
end
|
Instance Attribute Details
14
15
16
|
# File 'lib/contrast/agent/protect/rule/input_classification/match_rates.rb', line 14
def input_matches
@input_matches
end
|
16
17
18
|
# File 'lib/contrast/agent/protect/rule/input_classification/match_rates.rb', line 16
def input_mismatches
@input_mismatches
end
|
#request_matches ⇒ Integer
18
19
20
|
# File 'lib/contrast/agent/protect/rule/input_classification/match_rates.rb', line 18
def request_matches
@request_matches
end
|
#score_level ⇒ String
20
21
22
|
# File 'lib/contrast/agent/protect/rule/input_classification/match_rates.rb', line 20
def score_level
@score_level
end
|
Instance Method Details
#empty? ⇒ Boolean
47
48
49
|
# File 'lib/contrast/agent/protect/rule/input_classification/match_rates.rb', line 47
def empty?
super && @input_matches.zero? && @input_mismatches.zero? && @request_matches.zero?
end
|
Increase the match count for the given rule_id and input.
34
35
36
|
# File 'lib/contrast/agent/protect/rule/input_classification/match_rates.rb', line 34
def increase_match_for_input
@input_matches += 1
end
|
#increase_match_for_request ⇒ Object
increase the missmatch count for the given rule_id and input.
43
44
45
|
# File 'lib/contrast/agent/protect/rule/input_classification/match_rates.rb', line 43
def increase_match_for_request
@request_matches += 1
end
|
38
39
40
|
# File 'lib/contrast/agent/protect/rule/input_classification/match_rates.rb', line 38
def increase_mismatch_for_input
@input_mismatches += 1
end
|
#to_fields ⇒ Hash
Returns Agent Telemetry reportable fields.
54
55
56
57
58
59
60
|
# File 'lib/contrast/agent/protect/rule/input_classification/match_rates.rb', line 54
def to_fields
{
"#{ to_field_title }.input_matches" => input_matches,
"#{ to_field_title }.input_mismatches" => input_mismatches,
"#{ to_field_title }.request_matches" => request_matches
}
end
|