Class: CvssSuite::Cvss

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

Overview

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

Direct Known Subclasses

Cvss31AndBefore, Cvss40AndLater, InvalidCvss

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(vector) ⇒ Cvss

Creates a new CVSS vector by a vector.

Raises an exception if it is called on Cvss class.



18
19
20
21
22
23
24
25
# File 'lib/cvss_suite/cvss.rb', line 18

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

  @vector = vector
  @properties = []
  extract_metrics
  init_metrics
end

Instance Attribute Details

#baseObject (readonly)

Metric of a CVSS vector.



12
13
14
# File 'lib/cvss_suite/cvss.rb', line 12

def base
  @base
end

Instance Method Details

#severityObject

Returns the severity of the CVSS vector.



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/cvss_suite/cvss.rb', line 29

def severity
  check_validity

  score = overall_score

  if score <= 0.0
    'None'
  elsif (0.1..3.9).cover? score
    'Low'
  elsif (4.0..6.9).cover? score
    'Medium'
  elsif (7.0..8.9).cover? score
    'High'
  elsif (9.0..10.0).cover? score
    'Critical'
  else
    'None'
  end
end

#vectorObject

Returns the vector itself.



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

def vector
  @vector.to_s
end