Class: SemgrepWebApp::Exposures

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

Overview

Filter by exposure (reachability type). Only applies for sca findings. Reachability is the ability of an attacker to access a vulnerability in a system.

Constant Summary collapse

EXPOSURES =
[
  # TODO: Write general description for REACHABLE
  REACHABLE = 'reachable'.freeze,

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

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

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

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

Class Method Summary collapse

Class Method Details

.from_value(value, default_value = REACHABLE) ⇒ Object



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/semgrep_web_app/models/exposures.rb', line 34

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

  str = value.to_s.strip

  case str.downcase
  when 'reachable' then REACHABLE
  when 'always_reachable' then ALWAYS_REACHABLE
  when 'conditionally_reachable' then CONDITIONALLY_REACHABLE
  when 'unreachable' then UNREACHABLE
  when 'unknown' then UNKNOWN
  else
    default_value
  end
end

.validate(value) ⇒ Object



28
29
30
31
32
# File 'lib/semgrep_web_app/models/exposures.rb', line 28

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

  EXPOSURES.include?(value)
end