class NVD::JSONFeeds::Schema::CVEFeed
Represents the parsed contents of a JSON CVE feed.
Constants
- DATA_FORMATS
- DATA_TYPES
Attributes
The CVE items.
@return [Array<CVEItem>]
The feed format.
@return [:MITRE]
The number of CVEs.
@return [Integer, nil]
The feed timestamp.
@return [DateTime, nil]
The feed type.
@return [:CVE]
The feed format.
@return [:MITRE]
The number of CVEs.
@return [Integer, nil]
The feed timestamp.
@return [DateTime, nil]
The feed type.
@return [:CVE]
Public Class Methods
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_feed.rb, line 94 def self.from_json(json) { data_type: DATA_TYPES.fetch(json.fetch('CVE_data_type')), data_format: DATA_FORMATS.fetch(json.fetch('CVE_data_format')), **super(json), data_number_of_cves: json.fetch('CVE_data_numberOfCVEs').to_i, data_timestamp: if (timestamp = json['CVE_data_timestamp']) Timestamp.parse(timestamp) end, cve_items: json.fetch('CVE_Items').map(&CVEItem.method(:load)) } end
Loads the JSON feed data from the parsed JSON.
@param [Hash{String => Object}] json
The parsed JSON.
@return [JSONFeed]
The loaded JSON data.
# File lib/nvd/json_feeds/schema/cve_feed.rb, line 119 def self.load(json) new(**from_json(json)) end
Initializes the JSON feed.
@param [:MITRE] data_format
@param [:CVE] data_type
@param [Integer, nil] data_number_of_cves
@param [DateTime, nil] data_timestamp
@param [Array<CVEItem>] cve_items
NVD::JSONFeeds::Schema::HasDataVersion::new
# File lib/nvd/json_feeds/schema/cve_feed.rb, line 70 def initialize(data_format: , data_type: , data_number_of_cves: nil, data_timestamp: nil, cve_items: , **kwargs) super(**kwargs) @data_format = data_format @data_type = data_type @data_number_of_cves = data_number_of_cves @data_timestamp = data_timestamp @cve_items = cve_items end
Public Instance Methods
Enumerates over each CVE item in the feed.
@yield [cve_itme]
The given block will be passed each CVE Item.
@yieldparam [CVEItem] cve_item
A CVE Item in the feed.
@return [Enumerator]
If no block is given, an enumerator will be returned.
# File lib/nvd/json_feeds/schema/cve_feed.rb, line 135 def each(&block) @cve_items.each(&block) end