Class: HostStatus::CveStatus

Inherits:
Status
  • Object
show all
Defined in:
app/models/host_status/cve_status.rb

Overview

Host status entry reflecting latest CVE scan severities.

Constant Summary collapse

CVE_SCANNER_STATUS_NONE =
0
CVE_SCANNER_STATUS_LOW =
1
CVE_SCANNER_STATUS_MEDIUM =
2
CVE_SCANNER_STATUS_CRITICAL_HIGH =
3

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.status_nameObject



11
12
13
# File 'app/models/host_status/cve_status.rb', line 11

def self.status_name
  N_('CVE')
end

Instance Method Details

#to_global(_options = {}) ⇒ Object



30
31
32
33
34
35
36
37
38
39
# File 'app/models/host_status/cve_status.rb', line 30

def to_global(_options = {})
  case latest_scan_severity
  when :critical_high
    HostStatus::Global::ERROR
  when :medium, :none
    HostStatus::Global::WARN
  else
    HostStatus::Global::OK
  end
end

#to_label(_options = {}) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'app/models/host_status/cve_status.rb', line 15

def to_label(_options = {})
  case latest_scan_severity
  when :critical_high
    N_('Critical or high CVEs')
  when :medium
    N_('Medium CVEs')
  when :low
    N_('Low CVEs')
  when :none
    N_('No CVE scans')
  else
    N_('No CVEs')
  end
end

#to_status(_options = {}) ⇒ Object



41
42
43
44
45
46
47
48
49
50
51
52
# File 'app/models/host_status/cve_status.rb', line 41

def to_status(_options = {})
  case latest_scan_severity
  when :critical_high
    CVE_SCANNER_STATUS_CRITICAL_HIGH
  when :medium
    CVE_SCANNER_STATUS_MEDIUM
  when :low
    CVE_SCANNER_STATUS_LOW
  else
    CVE_SCANNER_STATUS_NONE
  end
end