Class: SemgrepWebApp::State

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

Overview

The finding's resolution state. Managed only by changes detected at scan time, the state is combined with triage_state to ultimately determine a final status which is exposed in the UI and API

Constant Summary collapse

STATE =
[
  # TODO: Write general description for FIXED
  FIXED = 'fixed'.freeze,

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

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

Class Method Summary collapse

Class Method Details

.from_value(value, default_value = FIXED) ⇒ Object



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

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

  str = value.to_s.strip

  case str.downcase
  when 'fixed' then FIXED
  when 'muted' then MUTED
  when 'unresolved' then UNRESOLVED
  else
    default_value
  end
end

.validate(value) ⇒ Object



22
23
24
25
26
# File 'lib/semgrep_web_app/models/state.rb', line 22

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

  STATE.include?(value)
end