Class: SemgrepWebApp::Verdict

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

Overview

| value | description | |-------|---------------| | VERDICT_TRUE_POSITIVE | | | VERDICT_FALSE_POSITIVE | | | VERDICT_NO_VERDICT | |

Constant Summary collapse

VERDICT =
[
  # TODO: Write general description for VERDICT_TRUE_POSITIVE
  VERDICT_TRUE_POSITIVE = 'VERDICT_TRUE_POSITIVE'.freeze,

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

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

Class Method Summary collapse

Class Method Details

.from_value(value, default_value = VERDICT_TRUE_POSITIVE) ⇒ Object



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

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

  str = value.to_s.strip

  case str.downcase
  when 'verdict_true_positive' then VERDICT_TRUE_POSITIVE
  when 'verdict_false_positive' then VERDICT_FALSE_POSITIVE
  when 'verdict_no_verdict' then VERDICT_NO_VERDICT
  else
    default_value
  end
end

.validate(value) ⇒ Object



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

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

  VERDICT.include?(value)
end