Sha256: a3d887d29de2925b2dde7f8d5287cfa474c7e89e269032d3b8eff7fd5674c85d

Contents?: true

Size: 1.36 KB

Versions: 2

Compression:

Stored size: 1.36 KB

Contents

# CVSS-Suite, a Ruby gem to manage the CVSS vector
#
# Copyright (c) Siemens AG, 2019
#
# Authors:
#   Oliver Hambörger <oliver.hamboerger@siemens.com>
#
# This work is licensed under the terms of the MIT license.
# See the LICENSE.md file in the top-level directory.

require_relative '../cvss'
require_relative 'cvss31_base'
require_relative 'cvss31_temporal'
require_relative 'cvss31_environmental'
require_relative '../helpers/cvss31_helper'

##
# This class represents a CVSS vector in version 3.1.

module CvssSuite
  class Cvss31 < Cvss
    ##
    # Returns the Version of the CVSS vector.

    def version
      3.1
    end

    ##
    # Returns the Base Score of the CVSS vector.

    def base_score
      check_validity
      Cvss31Helper.round_up(@base.score)
    end

    ##
    # Returns the Temporal Score of the CVSS vector.

    def temporal_score
      Cvss31Helper.round_up(Cvss31Helper.round_up(@base.score) * @temporal.score)
    end

    ##
    # Returns the Environmental Score of the CVSS vector.

    def environmental_score
      return temporal_score unless @environmental.valid?

      Cvss31Helper.round_up(@environmental.score(@base, @temporal))
    end

    private

    def init_metrics
      @base = Cvss31Base.new(@properties)
      @temporal = Cvss31Temporal.new(@properties)
      @environmental = Cvss31Environmental.new(@properties)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
cvss-suite-1.2.3 lib/cvss_suite/cvss31/cvss31.rb
cvss-suite-1.2.2 lib/cvss_suite/cvss31/cvss31.rb