Class: Contrast::AgentLib::EvalResult

Inherits:
Object
  • Object
show all
Defined in:
lib/contrast/agent_lib/return_types/eval_result.rb

Overview

This class will hold resulst received form AgentLib structs.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(hsh) ⇒ EvalResult

Init a new EvalResult, and translate results to usable for reporting values.

Parameters:

  • hsh (Hash, nil)

    return from AgentLib populated struct.



26
27
28
29
30
31
32
# File 'lib/contrast/agent_lib/return_types/eval_result.rb', line 26

def initialize hsh
  return unless hsh&.cs__is_a?(Hash)

  @rule_id = Contrast::AGENT_LIB.rule_set.key(hsh[:rule_id])
  @input_type = Contrast::AGENT_LIB.input_set.key(hsh[:input_type])
  @score = hsh[:score]
end

Instance Attribute Details

#input_typeString

Type of the input.

Returns:



15
16
17
# File 'lib/contrast/agent_lib/return_types/eval_result.rb', line 15

def input_type
  @input_type
end

#rule_idString

Name of the Protect rule analyzed.

Returns:



12
13
14
# File 'lib/contrast/agent_lib/return_types/eval_result.rb', line 12

def rule_id
  @rule_id
end

#scoreObject

Score of the input after AgentLib Analysis



20
21
22
# File 'lib/contrast/agent_lib/return_types/eval_result.rb', line 20

def score
  @score
end

Instance Method Details

#to_controlled_hashObject

Used in specs.



35
36
37
38
39
40
41
# File 'lib/contrast/agent_lib/return_types/eval_result.rb', line 35

def to_controlled_hash
  {
      rule_id: rule_id,
      input_type: input_type,
      score: score
  }
end