Class: SemgrepWebApp::Confidence7

Inherits:
Object
  • Object
show all
Defined in:
lib/semgrep_web_app/models/confidence7.rb

Overview

Confidence of the finding. | value | description | |-------|---------------| | CONFIDENCE_HIGH | | | CONFIDENCE_MEDIUM | | | CONFIDENCE_LOW | |

Constant Summary collapse

CONFIDENCE7 =
[
  # TODO: Write general description for CONFIDENCE_HIGH
  CONFIDENCE_HIGH = 'CONFIDENCE_HIGH'.freeze,

  # TODO: Write general description for CONFIDENCE_MEDIUM
  CONFIDENCE_MEDIUM = 'CONFIDENCE_MEDIUM'.freeze,

  # TODO: Write general description for CONFIDENCE_LOW
  CONFIDENCE_LOW = 'CONFIDENCE_LOW'.freeze
].freeze

Class Method Summary collapse

Class Method Details

.from_value(value, default_value = CONFIDENCE_HIGH) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/semgrep_web_app/models/confidence7.rb', line 27

def self.from_value(value, default_value = CONFIDENCE_HIGH)
  return default_value if value.nil?

  str = value.to_s.strip

  case str.downcase
  when 'confidence_high' then CONFIDENCE_HIGH
  when 'confidence_medium' then CONFIDENCE_MEDIUM
  when 'confidence_low' then CONFIDENCE_LOW
  else
    default_value
  end
end

.validate(value) ⇒ Object



21
22
23
24
25
# File 'lib/semgrep_web_app/models/confidence7.rb', line 21

def self.validate(value)
  return false if value.nil?

  CONFIDENCE7.include?(value)
end