Class: Cvss::Engine

Inherits:
Object
  • Object
show all
Includes:
Helpers, Parser
Defined in:
lib/cvss.rb

Instance Attribute Summary

Attributes included from Parser

#base

Instance Method Summary collapse

Methods included from Helpers

#data_availability, #data_confidentiality, #data_integrity

Methods included from Parser

#parse

Instance Method Details

#score(vector) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/cvss.rb', line 10

def score(vector)
  # AV 
  #   L = 0.395
  #   A = 0.646
  #   N = 1
  # AC
  #   H = 0.35
  #   M = 0.61
  #   L = 0.71
  # AU
  #   M = 0.45
  #   S = 0.56
  #   N = 0.704
  # C
  #   N = 0
  #   P = 0.275
  #   C = 0.660
  # I 
  #   N = 0
  #   P = 0.275
  #   C = 0.660
  # A
  #   N = 0
  #   P = 0.275
  #   C = 0.660
  return -1 unless parse(vector)
  av = {:L => 0.395, :A=> 0.646, :N=>1}
  ac = {:H => 0.35, :M=>0.61, :L=>0.71}
  au = {:M=>0.45, :S=>0.56, :N=>0.704 }

  exploitability = 20 * av[@base[:av].to_sym] * ac[@base[:ac].to_sym] * au[@base[:au].to_sym]
  c = {:N=>0, :P=>0.275, :C=>0.660}
  i = {:N=>0, :P=>0.275, :C=>0.660}
  a = {:N=>0, :P=>0.275, :C=>0.660}

  impact = 10.41 * (1 - (1-c[@base[:c].to_sym]) * (1-i[@base[:i].to_sym]) * (1-a[@base[:a].to_sym]))
  f = 0
  f = 1.176 unless impact == 0

  (((0.6 * impact) + (0.4*exploitability) - 1.5) * f).round(1)

end