Class: CvssSuite::Cvss31AndBefore

Inherits:
Cvss
  • Object
show all
Defined in:
lib/cvss_suite/cvss_31_and_before.rb

Overview

This class represents any CVSS vector. Do not instantiate this class!

Direct Known Subclasses

Cvss2, Cvss3, Cvss31

Instance Attribute Summary collapse

Attributes inherited from Cvss

#base

Instance Method Summary collapse

Methods inherited from Cvss

#severity, #vector

Constructor Details

#initialize(vector) ⇒ Cvss31AndBefore

Creates a new CVSS vector by a vector, for all CVSS versions through 3.1.

Raises an exception if it is called on Cvss31AndBefore class.



20
21
22
23
24
# File 'lib/cvss_suite/cvss_31_and_before.rb', line 20

def initialize(vector)
  raise CvssSuite::Errors::InvalidParentClass, 'Do not instantiate this class!' if instance_of? Cvss31AndBefore

  super
end

Instance Attribute Details

#environmentalObject (readonly)

Metric of a CVSS vector for CVSS 2, 3, 3.1.



14
15
16
# File 'lib/cvss_suite/cvss_31_and_before.rb', line 14

def environmental
  @environmental
end

#temporalObject (readonly)

Metric of a CVSS vector for CVSS 2, 3, 3.1.



14
15
16
# File 'lib/cvss_suite/cvss_31_and_before.rb', line 14

def temporal
  @temporal
end

Instance Method Details

#overall_scoreObject

Returns the Overall Score of the CVSS vector.



41
42
43
44
45
46
47
# File 'lib/cvss_suite/cvss_31_and_before.rb', line 41

def overall_score
  check_validity
  return temporal_score if @temporal.valid? && !@environmental.valid?
  return environmental_score if @environmental.valid?

  base_score
end

#valid?Boolean

Returns if CVSS vector is valid.

Returns:

  • (Boolean)


28
29
30
31
32
33
34
35
36
37
# File 'lib/cvss_suite/cvss_31_and_before.rb', line 28

def valid?
  if @amount_of_properties >= required_amount_of_properties
    entered_keys = @properties.collect { |p| p[:name] }
    return false if (entered_keys - allowed_abbreviations).size.positive?

    check_metrics_validity
  else
    false
  end
end