Sha256: 46041a2c953e21517e3cb6aaaa847d5767ee46e1c424451b28d417c8afc776c4

Contents?: true

Size: 1.04 KB

Versions: 16

Compression:

Stored size: 1.04 KB

Contents

module ForemanOpenscap
  class OvalStatus < ::HostStatus::Status
    PATCHED = 0
    VULNERABLE = 1
    PATCH_AVAILABLE = 2

    def self.status_name
      N_('OVAL scan')
    end

    def to_label(options = {})
      case to_status
      when PATCHED
        N_('No Vulnerabilities found')
      when VULNERABLE
        N_("%s vulnerabilities found") % host.cves_without_errata.count
      when PATCH_AVAILABLE
        N_("%s vulnerabilities with available patch found") % host.cves_with_errata.count
      else
        N_('Unknown OVAL status')
      end
    end

    def to_global(options = {})
      case to_status
      when PATCHED
        ::HostStatus::Global::OK
      when VULNERABLE
        ::HostStatus::Global::WARN
      when PATCH_AVAILABLE
        ::HostStatus::Global::ERROR
      end
    end

    def relevant?(options = {})
      host.combined_oval_policies.any?
    end

    def to_status(options = {})
      return PATCH_AVAILABLE if host.cves_with_errata.any?
      return VULNERABLE if host.cves_without_errata.any?
      PATCHED
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
foreman_openscap-8.0.0 app/models/foreman_openscap/oval_status.rb
foreman_openscap-7.1.1 app/models/foreman_openscap/oval_status.rb
foreman_openscap-7.1.0 app/models/foreman_openscap/oval_status.rb
foreman_openscap-7.0.0 app/models/foreman_openscap/oval_status.rb
foreman_openscap-6.0.0 app/models/foreman_openscap/oval_status.rb
foreman_openscap-5.2.3 app/models/foreman_openscap/oval_status.rb
foreman_openscap-5.2.2 app/models/foreman_openscap/oval_status.rb
foreman_openscap-5.1.1 app/models/foreman_openscap/oval_status.rb
foreman_openscap-5.2.1 app/models/foreman_openscap/oval_status.rb
foreman_openscap-5.2.0 app/models/foreman_openscap/oval_status.rb
foreman_openscap-5.1.0 app/models/foreman_openscap/oval_status.rb
foreman_openscap-5.0.0 app/models/foreman_openscap/oval_status.rb
foreman_openscap-4.3.3 app/models/foreman_openscap/oval_status.rb
foreman_openscap-4.3.2 app/models/foreman_openscap/oval_status.rb
foreman_openscap-4.3.1 app/models/foreman_openscap/oval_status.rb
foreman_openscap-4.3.0 app/models/foreman_openscap/oval_status.rb