class CVESchema::CVE::DataMeta

Represents the `“CVE_data_meta”` JSON object.

Constants

STATES

Attributes

assigner[R]

The assigner's email address.

@return [String]

date_assigned[R]

Date assigned.

@return [DateTime, nil]

date_public[R]

Date published publically.

@return [DateTime, nil]

date_requested[R]

Date requested.

@return [DateTime, nil]

id[R]

The CVE ID.

@return [ID]

replaced_by[R]

List of IDs that replaced the CVE.

@return [Array<ID>, nil]

requester[R]

Requester email address.

@return [String, nil]

serial[R]

@return [Integer, nil]

state[R]

@return [:PUBLIC, :RESERVED, :REPLACED_BY, :SPLIT_FROM, :MERGED_TO, nil]

title[R]

@return [String, nil]

updated[R]

Date last updated.

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

@raise [MissingJSONKey]

The `"ID"` or `"ASSIGNER"` JSON keys were missing.

@raise [UnknownJSONValue]

The `"STATE"` JSON value was unknown.

@api semipublic

# File lib/cve_schema/cve/data_meta.rb, line 136
def self.from_json(json)
  {
    id: if (id = json['ID'])
          ID.parse(id)
        else
          raise MissingJSONKey.new('ID')
        end,

    assigner: json['ASSIGNER'] || raise(MissingJSONKey.new('ASSIGNER')),

    updated: json['UPDATED'] && Timestamp.parse(json['UPDATED']),
    serial:  json['SERIAL'],
    date_requested: json['DATE_REQUESTED'] && Timestamp.parse(json['DATE_REQUESTED']),
    date_assigned: json['DATE_ASSIGNED'] && Timestamp.parse(json['DATE_ASSIGNED']),
    date_public: json['DATE_PUBLIC'] && Timestamp.parse(json['DATE_PUBLIC']),
    requester: json['REQUESTER'],
    replaced_by: json['REPLACED_BY'] && json['REPLACED_BY'].split(/,\s*/).map { |id| ID.parse(id) },
    state: if json['STATE']
             STATES.fetch(json['STATE']) do
               raise UnknownJSONValue.new('STATE',json['STATE'])
             end
           end,
    title: json['TITLE']
  }
end
load(json) click to toggle source

Loads the data-meta object from the parsed JSON.

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

The parsed JSON.

@return [self]

The loaded data-meta object.

@raise [MissingJSONKey]

The `"ID"` or `"ASSIGNER"` JSON keys were missing.

@raise [UnknownJSONValue]

The `"STATE"` JSON value was unknown.

@api semipublic

# File lib/cve_schema/cve/data_meta.rb, line 179
def self.load(json)
  new(**from_json(json))
end
new(id: , assigner: , updated: nil, serial: nil, date_requested: nil, date_assigned: nil, date_public: nil, requester: nil, replaced_by: nil, state: nil, title: nil) click to toggle source

Initializes the data-meta object.

@param [ID] id

@param [String] assigner

@param [DateTime, nil] updated

@param [Integer, nil] serial

@param [DateTime, nil] date_requested

@param [DateTime, nil] date_assigned

@param [DateTime, nil] date_public

@param [String, nil] requester

@param [Array<ID>, nil] replaced_by

@param [:PUBLIC, :RESERVED, :REPLACED_BY, :SPLIT_FROM, :MERGED_TO, nil] state

@param [String, nil] title

# File lib/cve_schema/cve/data_meta.rb, line 96
def initialize(id: , assigner: , updated: nil,
                                 serial: nil,
                                 date_requested: nil,
                                 date_assigned: nil,
                                 date_public: nil,
                                 requester: nil,
                                 replaced_by: nil,
                                 state: nil,
                                 title: nil)
  @id       = id
  @assigner = assigner

  @updated        = updated
  @serial         = serial
  @date_requested = date_requested
  @date_assigned  = date_assigned
  @date_public    = date_public
  @requester      = requester
  @replaced_by    = replaced_by
  @state          = state
  @title          = title
end