Module: CertBot::Data::Severity

Defined in:
lib/cert_bot/data/severity.rb

Overview

This module holds the severity rating defined by the BSI

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.string_mappingHash (private)

Returns the mapping from severity to its string representation.

Returns:

  • (Hash)

    the mapping from severity to its string representation



23
24
25
# File 'lib/cert_bot/data/severity.rb', line 23

def string_mapping
  @string_mapping
end

.valuesHash (readonly)

Returns the mapping severity to all rating higher of equal to the value.

Returns:

  • (Hash)

    the mapping severity to all rating higher of equal to the value



12
13
14
# File 'lib/cert_bot/data/severity.rb', line 12

def values
  @values
end

Class Method Details

.get_mapping_for(severity_string) ⇒ Symbol

module method to retrieve the severity symbol to the given severity string

Returns:

  • (Symbol)

    returns the severity symbol or nil if the string could not be found



49
50
51
52
53
54
55
# File 'lib/cert_bot/data/severity.rb', line 49

def self.get_mapping_for(severity_string)
  initialize if (@string_mapping.eql?(nil))
  @string_mapping.each_pair { |key, value|
    return key if (value.include?(severity_string))
  }
  nil
end

.initializeObject

initialization of the static mapping values



15
16
17
18
# File 'lib/cert_bot/data/severity.rb', line 15

def initialize
  initialize_values
  initialize_mapping
end

.initialize_mappingObject (private)

initializes the mapping hash



36
37
38
39
40
41
42
43
# File 'lib/cert_bot/data/severity.rb', line 36

def initialize_mapping
  @string_mapping = Hash.new
  @string_mapping[:low] = ["low", "niedrig"]
  @string_mapping[:medium] = ["medium", "mittel"]
  @string_mapping[:high] = ["high", "hoch"]
  @string_mapping[:critical] = ["critical", "kritisch"]
  nil
end

.initialize_valuesObject (private)

initializes the value hash



26
27
28
29
30
31
32
33
# File 'lib/cert_bot/data/severity.rb', line 26

def initialize_values
  @values = Hash.new
  @values[:low] = [:low, :medium, :high, :critical]
  @values[:medium] = [:medium, :high, :critical]
  @values[:high] = [:high, :critical]
  @values[:critical] = [:critical]
  nil
end