Class: Contrast::Agent::Protect::InputClassification::CachedResult

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

Overview

This Class with store the input classification results for a given user input.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(result, request_id) ⇒ CachedResult

Initialize Input Classification Cached Result

Parameters:



22
23
24
25
# File 'lib/contrast/agent/protect/rule/input_classification/cached_result.rb', line 22

def initialize result, request_id
  @result = result.dup if result&.cs__is_a?(Contrast::Agent::Reporting::InputAnalysisResult)
  @request_id = request_id
end

Instance Attribute Details

#request_idInteger (readonly)

Returns:

  • (Integer)


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

def request_id
  @request_id
end

#resultString (readonly)

Returns:



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

def result
  @result
end

Instance Method Details

#empty?Boolean

Check if the input classification result is empty.

Returns:

  • (Boolean)


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

def empty?
  Contrast::Utils::DuckUtils.empty_duck?(@result) && Contrast::Utils::DuckUtils.empty_duck?(@request_id)
end