class NVD::JSONFeeds::Schema::CVEItem

Represents the `“CVE_Item”` JSON object.

Attributes

configurations[R]

@return [Configurations, nil]

cve[R]

The CVE object.

@return [CVESchema::CVE]

impact[R]

@return [Impact, nil]

last_modified_date[R]

@return [DateTime, nil]

published_date[R]

@return [DateTime, nil]

Public Class Methods

from_json(json) click to toggle source

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

@param [Hash{String => Object}] json

The parsed JSON.

@return [Hash{Symbol => Object}]

The mapped Symbol Hash.
# File lib/nvd/json_feeds/schema/cve_item.rb, line 58
def self.from_json(json)
  {
    cve: CVESchema::CVE.load(json.fetch('cve')),
    configurations: if (configurations = json['configurations'])
                      Configurations.load(configurations)
                    end,
    impact: if (impact = json['impact'])
              Impact.load(impact)
            end,

    published_date: if (published_date = json['publishedDate'])
                      Timestamp.parse(published_date)
                    end,

    last_modified_date: if (last_modified_date = json['lastModifiedDate'])
                          Timestamp.parse(last_modified_date)
                        end
  }
end
load(json) click to toggle source

Loads the CVE Item object from the parsed JSON.

@param [Hash{String => Object}] json

The parsed JSON.

@return [CVEItem]

The loaded CVE Item object.
# File lib/nvd/json_feeds/schema/cve_item.rb, line 87
def self.load(json)
  new(**from_json(json))
end
new(cve: , configurations: nil, impact: nil, published_date: nil, last_modified_date: nil) click to toggle source

Initializes the CVE Item object.

@param [CVESchema::CVE] cve

The CVE object.
# File lib/nvd/json_feeds/schema/cve_item.rb, line 37
def initialize(cve: , configurations: nil,
               impact: nil,
               published_date: nil,
               last_modified_date: nil)
  @cve = cve

  @configurations     = configurations
  @impact             = impact
  @published_date     = published_date
  @last_modified_date = last_modified_date
end