Class: NVD::JSONFeeds::Schema::Impact::BaseMetricV3

Inherits:
Object
  • Object
show all
Defined in:
lib/nvd/json_feeds/schema/impact/base_metric_v3.rb

Overview

Represents the "baseMetricV3" value.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(cvss_v3:, exploitability_score: nil, impact_score: nil) ⇒ BaseMetricV3

Initializes the base metric v3 object.

Parameters:

  • cvss_v3 (CVSSv3)
  • exploitability_score (Float, nil) (defaults to: nil)
  • impact_score (Float, nil) (defaults to: nil)


36
37
38
39
40
41
42
# File 'lib/nvd/json_feeds/schema/impact/base_metric_v3.rb', line 36

def initialize(cvss_v3: , exploitability_score: nil,
                          impact_score: nil)
  @cvss_v3 = cvss_v3

  @exploitability_score = exploitability_score
  @impact_score         = impact_score
end

Instance Attribute Details

#cvss_v3CVSSv3 (readonly)

The CVSSv3 data.

Returns:



15
16
17
# File 'lib/nvd/json_feeds/schema/impact/base_metric_v3.rb', line 15

def cvss_v3
  @cvss_v3
end

#exploitability_scoreFloat? (readonly)

The exploitability score.

Returns:

  • (Float, nil)


20
21
22
# File 'lib/nvd/json_feeds/schema/impact/base_metric_v3.rb', line 20

def exploitability_score
  @exploitability_score
end

#impact_scoreFloat? (readonly)

The impact score.

Returns:

  • (Float, nil)


25
26
27
# File 'lib/nvd/json_feeds/schema/impact/base_metric_v3.rb', line 25

def impact_score
  @impact_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 Symbol Hash.



53
54
55
56
57
58
59
60
# File 'lib/nvd/json_feeds/schema/impact/base_metric_v3.rb', line 53

def self.from_json(json)
  {
    cvss_v3: CVSSv3.load(json.fetch('cvssV3')),

    exploitability_score: json['exploitabilityScore'],
    impact_score:         json['impactScore']
  }
end

.load(json) ⇒ BaseMetricV3

Loads the base metrics V3 object from the parsed JSON.

Parameters:

  • json (Hash{String => Object})

    The parsed JSON.

Returns:



71
72
73
# File 'lib/nvd/json_feeds/schema/impact/base_metric_v3.rb', line 71

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