Class: Contrast::Agent::Reporting::Settings::ExclusionBase

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

Overview

Base class to represent common exclusions fields.

Direct Known Subclasses

InputExclusion, UrlExclusion

Constant Summary collapse

BASE_ATTRIBUTES =
%i[name modes assess_rules protect_rules urls match_strategy].cs__freeze
STRATEGIES =
%w[ALL ONLY].cs__freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeExclusionBase

Returns a new instance of ExclusionBase.



25
26
27
28
# File 'lib/contrast/agent/reporting/settings/exclusion_base.rb', line 25

def initialize
  @modes = []
  @urls = []
end

Instance Attribute Details

#modesObject

Returns the value of attribute modes.



21
22
23
# File 'lib/contrast/agent/reporting/settings/exclusion_base.rb', line 21

def modes
  @modes
end

#nameObject

Base attribute for exclusion name. For ng response it corresponds only for the name of the exclusion, in the new server settings endpoint it is used to store the name of the input to be excluded.



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

def name
  @name
end

#urlsObject

Returns the value of attribute urls.



23
24
25
# File 'lib/contrast/agent/reporting/settings/exclusion_base.rb', line 23

def urls
  @urls
end

Instance Method Details

#assessBoolean

Returns does this exclusion apply to Assess or not.

Returns:

  • (Boolean)

    does this exclusion apply to Assess or not.



42
43
44
45
# File 'lib/contrast/agent/reporting/settings/exclusion_base.rb', line 42

def assess
  @_assess = modes&.include?('assess') if @_assess.nil?
  @_assess
end

#assess_rulesArray<String>

Array of all excluded assess rules.

Returns:



71
72
73
# File 'lib/contrast/agent/reporting/settings/exclusion_base.rb', line 71

def assess_rules
  @_assess_rules ||= assessment_rules
end

#assess_rules=(new_rules) ⇒ Array<String>

Setter for assess rules array.

Parameters:

Returns:



79
80
81
# File 'lib/contrast/agent/reporting/settings/exclusion_base.rb', line 79

def assess_rules= new_rules
  @_assess_rules = new_rules if new_rules.cs__is_a?(Array)
end

#match_strategyObject



31
32
33
# File 'lib/contrast/agent/reporting/settings/exclusion_base.rb', line 31

def match_strategy
  @_match_strategy ||= Contrast::Utils::ObjectShare::EMPTY_STRING
end

#match_strategy=(new_strategy) ⇒ Object

Parameters:

  • new_strategy (String)

    Set new input type.



37
38
39
# File 'lib/contrast/agent/reporting/settings/exclusion_base.rb', line 37

def match_strategy= new_strategy
  @_match_strategy = new_strategy if STRATEGIES.include?(new_strategy)
end

#protectBoolean

Returns does this exclusion apply to Protect or not.

Returns:

  • (Boolean)

    does this exclusion apply to Protect or not.



48
49
50
51
# File 'lib/contrast/agent/reporting/settings/exclusion_base.rb', line 48

def protect
  @_protect = modes&.include?('defend') if @_protect.nil?
  @_protect
end

#protect_rulesArray<String>

Array of all excluded protect rules.

Returns:



56
57
58
# File 'lib/contrast/agent/reporting/settings/exclusion_base.rb', line 56

def protect_rules
  @_protect_rules ||= rules
end

#protect_rules=(new_rules) ⇒ Array<String>

Setter for protect rules array.

Parameters:

Returns:



64
65
66
# File 'lib/contrast/agent/reporting/settings/exclusion_base.rb', line 64

def protect_rules= new_rules
  @_protect_rules = new_rules if new_rules.cs__is_a?(Array)
end

#to_controlled_hashObject



83
84
85
86
87
88
89
90
91
92
# File 'lib/contrast/agent/reporting/settings/exclusion_base.rb', line 83

def to_controlled_hash
  {
      name: name, # rubocop:disable Security/Module/Name
      modes: modes,
      urls: urls,
      assess_rules: assess_rules,
      protect_rules: protect_rules,
      match_strategy: match_strategy
  }
end