Class: CVESchema::CVE::Impact::CVSSv2::TM

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

Constant Summary collapse

E =
{'U' => :U, 'POC' => :POC, 'F' => :F, 'H' => :H, 'ND' => :ND}
RL =
{'OF' => :OF, 'TF' => :TF, 'W' => :W, 'U' => :U, 'ND' => :ND}
RC =
{'UC' => :UC, 'UR' => :UR, 'C' => :C, 'ND' => :ND}

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(e: nil, rl: nil, rc: nil, score: nil) ⇒ TM

Returns a new instance of TM.



135
136
137
138
139
140
# File 'lib/cve_schema/cve/impact/cvss_v2.rb', line 135

def initialize(e: nil, rl: nil, rc: nil, score: nil)
  @e = e
  @rl = rl
  @rc = rc
  @score = score
end

Instance Attribute Details

#e:U, ... (readonly)

Exploitability

Returns:

  • (:U, :POC, :F, :H, :ND)


114
115
116
# File 'lib/cve_schema/cve/impact/cvss_v2.rb', line 114

def e
  @e
end

#rc:UC, ... (readonly)

Report Confidence.

Returns:

  • (:UC, :UR, :C, :ND)


128
129
130
# File 'lib/cve_schema/cve/impact/cvss_v2.rb', line 128

def rc
  @rc
end

#rl:OF, ... (readonly)

Remediation Level.

Returns:

  • (:OF, :TF, :W, :U, :ND)


121
122
123
# File 'lib/cve_schema/cve/impact/cvss_v2.rb', line 121

def rl
  @rl
end

#scoreString? (readonly)

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

Returns:

  • (String, nil)


133
134
135
# File 'lib/cve_schema/cve/impact/cvss_v2.rb', line 133

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.



151
152
153
154
155
156
157
158
159
# File 'lib/cve_schema/cve/impact/cvss_v2.rb', line 151

def self.from_json(json)
  {
    e:  E[json['E']],
    rl: RL[json['RL']],
    rc: RC[json['RC']],

    score: json['SCORE']
  }
end

.load(json) ⇒ self

Loads the TM object from the parsed JSON.

Parameters:

  • json (Hash{String => Object})

    The parsed JSON.

Returns:

  • (self)

    The loaded TM object.



170
171
172
# File 'lib/cve_schema/cve/impact/cvss_v2.rb', line 170

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