Class: SemgrepWebApp::EpssProbability

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

Overview

Filter by EPSS probability (likelihood of exploit). Only applies for sca findings.

Constant Summary collapse

EPSS_PROBABILITY =
[
  # TODO: Write general description for LOW
  LOW = 'low'.freeze,

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

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

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

Class Method Summary collapse

Class Method Details

.from_value(value, default_value = LOW) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/semgrep_web_app/models/epss_probability.rb', line 30

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

  str = value.to_s.strip

  case str.downcase
  when 'low' then LOW
  when 'medium' then MEDIUM
  when 'high' then HIGH
  when 'none' then NONE
  else
    default_value
  end
end

.validate(value) ⇒ Object



24
25
26
27
28
# File 'lib/semgrep_web_app/models/epss_probability.rb', line 24

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

  EPSS_PROBABILITY.include?(value)
end