Class: NVD::JSONFeeds::Schema::Impact::BaseMetricV2

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

Overview

Represents the "baseMetricV2" value.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(cvss_v2: nil, severity: nil, exploitability_score: nil, impact_score: nil, ac_insuf_info: nil, obtain_all_privilege: nil, obtain_user_privilege: nil, obtain_other_privilege: nil, user_interaction_required: nil) ⇒ BaseMetricV2

Initializes the base metric V2 object.

Parameters:

  • cvss_v2 (CVSSv2, nil) (defaults to: nil)
  • severity (String, nil) (defaults to: nil)
  • exploitability_score (Float, nil) (defaults to: nil)
  • impact_score (Float, nil) (defaults to: nil)
  • ac_insuf_info (Boolean, nil) (defaults to: nil)
  • obtain_all_privilege (Boolean, nil) (defaults to: nil)
  • obtain_user_privilege (Boolean, nil) (defaults to: nil)
  • obtain_other_privilege (Boolean, nil) (defaults to: nil)
  • user_interaction_required (Boolean, nil) (defaults to: nil)


68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/nvd/json_feeds/schema/impact/base_metric_v2.rb', line 68

def initialize(cvss_v2: nil,
               severity: nil,
               exploitability_score: nil,
               impact_score: nil,
               ac_insuf_info: nil,
               obtain_all_privilege: nil,
               obtain_user_privilege: nil,
               obtain_other_privilege: nil,
               user_interaction_required: nil)
  @cvss_v2 = cvss_v2
  @severity = severity
  @exploitability_score = exploitability_score
  @impact_score = impact_score
  @ac_insuf_info = ac_insuf_info
  @obtain_all_privilege = obtain_all_privilege
  @obtain_user_privilege = obtain_user_privilege
  @obtain_other_privilege = obtain_other_privilege
  @user_interaction_required = user_interaction_required
end

Instance Attribute Details

#ac_insuf_infoBoolean? (readonly)

Returns:

  • (Boolean, nil)


33
34
35
# File 'lib/nvd/json_feeds/schema/impact/base_metric_v2.rb', line 33

def ac_insuf_info
  @ac_insuf_info
end

#cvss_v2CVSSv2? (readonly)

The CVSSv2 data.

Returns:



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

def cvss_v2
  @cvss_v2
end

#exploitability_scoreFloat? (readonly)

The exploitability score.

Returns:

  • (Float, nil)


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

def exploitability_score
  @exploitability_score
end

#impact_scoreFloat? (readonly)

The impact score.

Returns:

  • (Float, nil)


30
31
32
# File 'lib/nvd/json_feeds/schema/impact/base_metric_v2.rb', line 30

def impact_score
  @impact_score
end

#obtain_all_privilegeBoolean? (readonly)

Returns:

  • (Boolean, nil)


36
37
38
# File 'lib/nvd/json_feeds/schema/impact/base_metric_v2.rb', line 36

def obtain_all_privilege
  @obtain_all_privilege
end

#obtain_other_privilegeBoolean? (readonly)

Returns:

  • (Boolean, nil)


42
43
44
# File 'lib/nvd/json_feeds/schema/impact/base_metric_v2.rb', line 42

def obtain_other_privilege
  @obtain_other_privilege
end

#obtain_user_privilegeBoolean? (readonly)

Returns:

  • (Boolean, nil)


39
40
41
# File 'lib/nvd/json_feeds/schema/impact/base_metric_v2.rb', line 39

def obtain_user_privilege
  @obtain_user_privilege
end

#severityString? (readonly)

The severity.

Returns:

  • (String, nil)


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

def severity
  @severity
end

#user_interaction_requiredBoolean? (readonly)

Returns:

  • (Boolean, nil)


45
46
47
# File 'lib/nvd/json_feeds/schema/impact/base_metric_v2.rb', line 45

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



97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# File 'lib/nvd/json_feeds/schema/impact/base_metric_v2.rb', line 97

def self.from_json(json)
  {
    cvss_v2: if (value = json['cvssV2'])
               CVSSv2.load(value)
             end,

    severity:                  json['severity'],
    exploitability_score:      json['exploitabilityScore'],
    impact_score:              json['impactScore'],
    ac_insuf_info:             json['acInsufInfo'],
    obtain_all_privilege:      json['obtainAllPrivilege'],
    obtain_user_privilege:     json['obtainUserPrivilege'],
    obtain_other_privilege:    json['obtainOtherPrivilege'],
    user_interaction_required: json['userInteractionRequired']
  }
end

.load(json) ⇒ BaseMetricV2

Loads the base metrics V2 object from the parsed JSON.

Parameters:

  • json (Hash{String => Object})

    The parsed JSON.

Returns:



123
124
125
# File 'lib/nvd/json_feeds/schema/impact/base_metric_v2.rb', line 123

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