Class: CVESchema::CVE::Impact::CVSSv2::BM

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

Constant Summary collapse

AV =
{'L' => :L, 'A' => :A, 'N' => :N}
AC =
{'H' => :H, 'M' => :M, 'L' => :L}
AU =
{'M' => :M, 'S' => :S, 'N' => :N}
C =
{'N' => :N, 'P' => :P, 'C' => :C}
I =
{'N' => :N, 'P' => :P, 'C' => :C}
A =
{'N' => :N, 'P' => :P, 'C' => :C}

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(av: nil, ac: nil, au: nil, c: nil, i: nil, a: nil, score: nil) ⇒ BM

Returns a new instance of BM.



57
58
59
60
61
62
63
64
65
# File 'lib/cve_schema/cve/impact/cvss_v2.rb', line 57

def initialize(av: nil, ac: nil, au: nil, c: nil, i: nil, a: nil,
               score: nil)
  @av = av
  @ac = ac
  @c = c
  @i = i
  @a = a
  @score = score
end

Instance Attribute Details

#a:N, ... (readonly)

The Availability impact.

Returns:

  • (:N, :P, :C)


50
51
52
# File 'lib/cve_schema/cve/impact/cvss_v2.rb', line 50

def a
  @a
end

#ac:H, ... (readonly)

The Access Complexity.

Returns:

  • (:H, :M, :L)


22
23
24
# File 'lib/cve_schema/cve/impact/cvss_v2.rb', line 22

def ac
  @ac
end

#au:M, ... (readonly)

The Authentication

Returns:

  • (:M, :S, :N)


29
30
31
# File 'lib/cve_schema/cve/impact/cvss_v2.rb', line 29

def au
  @au
end

#av:L, ... (readonly)

The Access Vector.

Returns:

  • (:L, :A, :N)


15
16
17
# File 'lib/cve_schema/cve/impact/cvss_v2.rb', line 15

def av
  @av
end

#c:N, ... (readonly)

The Confidentiality impact.

Returns:

  • (:N, :P, :C)


36
37
38
# File 'lib/cve_schema/cve/impact/cvss_v2.rb', line 36

def c
  @c
end

#i:N, ... (readonly)

The Integrity impact.

Returns:

  • (:N, :P, :C)


43
44
45
# File 'lib/cve_schema/cve/impact/cvss_v2.rb', line 43

def i
  @i
end

#scoreString (readonly)

The CVSSv2 Base Metrics Group score assuming all elements are present.

Returns:

  • (String)


55
56
57
# File 'lib/cve_schema/cve/impact/cvss_v2.rb', line 55

def score
  @score
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.



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

def self.from_json(json)
  {
    av: AV[json['AV']],
    ac: AC[json['AC']],
    au: AU[json['AU']],
    c:  C[json['C']],
    i:  I[json['I']],
    a:  A[json['A']],

    score: json['SCORE']
  }
end

.load(json) ⇒ self

Loads the BM object from the parsed JSON.

Parameters:

  • json (Hash{String => Object})

    The parsed JSON.

Returns:

  • (self)

    The loaded BM object.



98
99
100
# File 'lib/cve_schema/cve/impact/cvss_v2.rb', line 98

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