Class: Contrast::Agent::Reporting::Settings::RuleDefinition

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

Overview

The keywords and patterns required for the input analysis of each rule with that capability.

Constant Summary collapse

ATTRIBUTES =
%i[name keywords patterns].cs__freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#nameObject

For the ServerSettings this name is not used instead it is used as key to the keywords and patterns arrays. It is used in the agent startup message.



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

def name
  @name
end

Instance Method Details

#keywordsarray<Contrast::Agent::Reporting::Settings::Keyword>

The words to search for in input that indicate an attack



24
25
26
# File 'lib/contrast/agent/reporting/settings/rule_definition.rb', line 24

def keywords
  @_keywords ||= []
end

#keywords=(keywords_array) ⇒ array<Contrast::Agent::Reporting::Settings::Keyword>

Set keywords.

Parameters:

  • keywords_array (Array)

Returns:



39
40
41
42
43
# File 'lib/contrast/agent/reporting/settings/rule_definition.rb', line 39

def keywords= keywords_array
  Contrast::Agent::Reporting::Settings::Helpers.array_to_iv(Contrast::Agent::Reporting::Settings::Keyword,
                                                            keywords,
                                                            keywords_array)
end

#patternsarray<Contrast::Agent::Reporting::Settings::Pattern>

A word or pattern whose presence in an input represents an attack



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

def patterns
  @_patterns ||= []
end

#patterns=(patterns_array) ⇒ array<Contrast::Agent::Reporting::Settings::Pattern>

Set patterns.

Parameters:

  • patterns_array (Array)

Returns:



49
50
51
52
53
# File 'lib/contrast/agent/reporting/settings/rule_definition.rb', line 49

def patterns= patterns_array
  Contrast::Agent::Reporting::Settings::Helpers.array_to_iv(Contrast::Agent::Reporting::Settings::Pattern,
                                                            patterns,
                                                            patterns_array)
end

#to_controlled_hashObject



55
56
57
58
59
60
61
# File 'lib/contrast/agent/reporting/settings/rule_definition.rb', line 55

def to_controlled_hash
  {
      name: name, # rubocop:disable Security/Module/Name
      keywords: keywords.map(&:to_controlled_hash),
      patterns: patterns.map(&:to_controlled_hash)
  }
end