Class: CvssSuite::Cvss2

Inherits:
Cvss31AndBefore show all
Defined in:
lib/cvss_suite/cvss2/cvss2.rb

Overview

This class represents a CVSS vector in version 2.

Instance Attribute Summary

Attributes inherited from Cvss31AndBefore

#environmental, #temporal

Attributes inherited from Cvss

#base

Instance Method Summary collapse

Methods inherited from Cvss31AndBefore

#initialize, #overall_score, #valid?

Methods inherited from Cvss

#initialize, #vector

Constructor Details

This class inherits a constructor from CvssSuite::Cvss31AndBefore

Instance Method Details

#base_scoreObject

Returns the Base Score of the CVSS vector.



44
45
46
47
# File 'lib/cvss_suite/cvss2/cvss2.rb', line 44

def base_score
  check_validity
  @base.score.round(1)
end

#environmental_scoreObject

Returns the Environmental Score of the CVSS vector.



57
58
59
60
61
# File 'lib/cvss_suite/cvss2/cvss2.rb', line 57

def environmental_score
  return temporal_score unless @environmental.valid?

  (@environmental.score @base, @temporal.score).round(1)
end

#severityObject

Returns the severity of the CVSSv2 base score. nvd.nist.gov/vuln-metrics/cvss



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/cvss_suite/cvss2/cvss2.rb', line 25

def severity
  check_validity

  score = base_score

  case score
  when 0.0..3.9
    'Low'
  when 4.0..6.9
    'Medium'
  when 7.0..10.0
    'High'
  else
    'None'
  end
end

#temporal_scoreObject

Returns the Temporal Score of the CVSS vector.



51
52
53
# File 'lib/cvss_suite/cvss2/cvss2.rb', line 51

def temporal_score
  (base_score * @temporal.score.to_d).round(1).to_f
end

#versionObject

Returns the Version of the CVSS vector.



19
20
21
# File 'lib/cvss_suite/cvss2/cvss2.rb', line 19

def version
  2
end