Class: Contrast::Agent::Reporting::InputAnalysis

Inherits:
Object
  • Object
show all
Defined in:
lib/contrast/agent/reporting/input_analysis/input_analysis.rb

Overview

This class will do ia analysis for our protect rules

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#inputsHash

Returns Stored request inputs for this context.

Returns:

  • (Hash)

    Stored request inputs for this context.



14
15
16
# File 'lib/contrast/agent/reporting/input_analysis/input_analysis.rb', line 14

def inputs
  @inputs
end

Instance Method Details

#analysed_rulesArray<String>

Records rules with input analysis for current request.

Returns:

  • (Array<String>)

    array with rule names.



26
27
28
# File 'lib/contrast/agent/reporting/input_analysis/input_analysis.rb', line 26

def analysed_rules
  @_analysed_rules ||= []
end

#no_inputs?Boolean

Check if the InputAnalysis is empty.

Returns:

  • (Boolean)


60
61
62
# File 'lib/contrast/agent/reporting/input_analysis/input_analysis.rb', line 60

def no_inputs?
  Contrast::Utils::DuckUtils.empty_duck?(inputs)
end

#record_analysed_rule(rule_name) ⇒ Object

We add the analysed rules to the list. The IA won’t be build for this rule, since already it’s already available.

Parameters:

  • rule_name (String)

    name to record.



68
69
70
# File 'lib/contrast/agent/reporting/input_analysis/input_analysis.rb', line 68

def record_analysed_rule rule_name
  analysed_rules << rule_name unless triggered_rules.include?(rule_name)
end

#record_rule_triggered(rule_name) ⇒ Object

We add the triggered rules to the list. After request analysis will skip this rule as already triggered.

Parameters:

  • rule_name (String)

    name to record.



76
77
78
# File 'lib/contrast/agent/reporting/input_analysis/input_analysis.rb', line 76

def record_rule_triggered rule_name
  triggered_rules << rule_name unless triggered_rules.include?(rule_name)
end

#requestObject

Returns our wrapper around the Rack::Request for this context



47
48
49
# File 'lib/contrast/agent/reporting/input_analysis/input_analysis.rb', line 47

def request
  @_request ||= nil
end

#request=(request) ⇒ Object

Sets current request

Parameters:



55
56
57
# File 'lib/contrast/agent/reporting/input_analysis/input_analysis.rb', line 55

def request= request
  @_request = request if request.instance_of?(Contrast::Agent::Request)
end

#resultsObject

result from input analysis



33
34
35
# File 'lib/contrast/agent/reporting/input_analysis/input_analysis.rb', line 33

def results
  @_results ||= []
end

#results=(results) ⇒ Object

result from input analysis



40
41
42
# File 'lib/contrast/agent/reporting/input_analysis/input_analysis.rb', line 40

def results= results
  @_results = results
end

#triggered_rulesArray<String>

Records rules triggered on sink.

Returns:

  • (Array<String>)

    array with rule names.



19
20
21
# File 'lib/contrast/agent/reporting/input_analysis/input_analysis.rb', line 19

def triggered_rules
  @_triggered_rules ||= []
end