Class: CVESchema::CVE::Impact::CVSSv3::BM

Inherits:
Object
  • Object
show all
Defined in:
lib/cve_schema/cve/impact/cvss_v3.rb

Overview

The Base Metric Group scoring information.

Constant Summary collapse

AV =
{'N' => :N, 'A' => :A, 'L' => :L, 'P' => :P}
AC =
{'L' => :L, 'H' => :H}
PR =
{'N' => :N, 'L' => :L, 'H' => :H}
UI =
{'N' => :N, 'R' => :R}
S =
{'U' => :U, 'C' => :C}
C =
{'H' => :H, 'L' => :L, 'N' => :N}
I =
{'H' => :H, 'L' => :L, 'N' => :N}
A =
{'H' => :H, 'L' => :L, 'N' => :N}

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(av: nil, ac: nil, pr: nil, ui: nil, s: nil, c: nil, i: nil, a: nil, score: nil) ⇒ BM

Initializes the BM object.



77
78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/cve_schema/cve/impact/cvss_v3.rb', line 77

def initialize(av: nil, ac: nil, pr: nil, ui: nil, s: nil, c: nil,
               i: nil, a: nil, score: nil)
  @av = av
  @ac = ac
  @pr = pr
  @ui = ui
  @s  = s
  @c  = c
  @i  = i
  @a  = a

  @score = score
end

Instance Attribute Details

#a:H, ... (readonly)

The Availability Impact

Returns:

  • (:H, :L, :N)


67
68
69
# File 'lib/cve_schema/cve/impact/cvss_v3.rb', line 67

def a
  @a
end

#ac:L, :H (readonly)

The Attack Complexity.

Returns:

  • (:L, :H)


25
26
27
# File 'lib/cve_schema/cve/impact/cvss_v3.rb', line 25

def ac
  @ac
end

#av:N, ... (readonly)

The Attack Vector.

Returns:

  • (:N, :A, :L, :P)


18
19
20
# File 'lib/cve_schema/cve/impact/cvss_v3.rb', line 18

def av
  @av
end

#c:H, ... (readonly)

The Confidentiality Impact.

Returns:

  • (:H, :L, :N)


53
54
55
# File 'lib/cve_schema/cve/impact/cvss_v3.rb', line 53

def c
  @c
end

#i:H, ... (readonly)

The Integrity Impact

Returns:

  • (:H, :L, :N)


60
61
62
# File 'lib/cve_schema/cve/impact/cvss_v3.rb', line 60

def i
  @i
end

#pr:N, ... (readonly)

The Privileges Required.

Returns:

  • (:N, :L, :H)


32
33
34
# File 'lib/cve_schema/cve/impact/cvss_v3.rb', line 32

def pr
  @pr
end

#s:U, :C (readonly)

The Scope

Returns:

  • (:U, :C)


46
47
48
# File 'lib/cve_schema/cve/impact/cvss_v3.rb', line 46

def s
  @s
end

#scoreString (readonly)

The CVSSv3 score.

Returns:

  • (String)


72
73
74
# File 'lib/cve_schema/cve/impact/cvss_v3.rb', line 72

def score
  @score
end

#ui:N, :R (readonly)

The User Interaction.

Returns:

  • (:N, :R)


39
40
41
# File 'lib/cve_schema/cve/impact/cvss_v3.rb', line 39

def ui
  @ui
end

Class Method Details

.from_json(json) ⇒ Hash{Symbol => Object}

Maps the parsed JSON to a Symbol Hash for #initialize.

Parameters:

  • json (Hash{String => Object})

    The parsed JSON.

Returns:

  • (Hash{Symbol => Object})

    The mapped Symbol Hash.



100
101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/cve_schema/cve/impact/cvss_v3.rb', line 100

def self.from_json(json)
  {
    av: AV[json['AV']],
    ac: AC[json['AC']],
    pr: PR[json['PR']],
    ui: UI[json['UI']],
    s:  S[json['S']],
    c:  C[json['C']],
    i:  I[json['I']],
    a:  A[json['A']],

    score: json['SCORE']
  }
end

.load(json) ⇒ BM

Loads the BM object from the parsed JSON.

Parameters:

  • json (Hash{String => Object})

    The parsed JSON.

Returns:

  • (BM)

    The loaded BM object.



124
125
126
# File 'lib/cve_schema/cve/impact/cvss_v3.rb', line 124

def self.load(json)
  new(**from_json(json))
end