Class: SemgrepWebApp::Status7

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

Overview

The current status of the scan | value | description | |-------|---------------| | SCAN_STATUS_RUNNING | The scan is currently running | | SCAN_STATUS_COMPLETED | The scan has completed successfully (0 or 1 exit code) | | SCAN_STATUS_PENDING | The scan is queued and waiting to start | | SCAN_STATUS_CANCELLED | The scan was cancelled before completion | | SCAN_STATUS_ERROR | The scan has exited with a failure (exit code not 0 or

  1. | | SCAN_STATUS_NEVER_FINISHED | The scan did not report an error or

success after over an hour |

Constant Summary collapse

STATUS7 =
[
  # TODO: Write general description for SCAN_STATUS_RUNNING
  SCAN_STATUS_RUNNING = 'SCAN_STATUS_RUNNING'.freeze,

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

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

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

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

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

Class Method Summary collapse

Class Method Details

.from_value(value, default_value = SCAN_STATUS_RUNNING) ⇒ Object



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/semgrep_web_app/models/status7.rb', line 42

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

  str = value.to_s.strip

  case str.downcase
  when 'scan_status_running' then SCAN_STATUS_RUNNING
  when 'scan_status_completed' then SCAN_STATUS_COMPLETED
  when 'scan_status_pending' then SCAN_STATUS_PENDING
  when 'scan_status_cancelled' then SCAN_STATUS_CANCELLED
  when 'scan_status_error' then SCAN_STATUS_ERROR
  when 'scan_status_never_finished' then SCAN_STATUS_NEVER_FINISHED
  else
    default_value
  end
end

.validate(value) ⇒ Object



36
37
38
39
40
# File 'lib/semgrep_web_app/models/status7.rb', line 36

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

  STATUS7.include?(value)
end