Class: CVESchema::CVE::DataMeta
- Inherits:
-
Object
- Object
- CVESchema::CVE::DataMeta
- Defined in:
- lib/cve_schema/cve/data_meta.rb
Overview
Represents the "CVE_data_meta"
JSON object.
Constant Summary collapse
- STATES =
{ 'PUBLIC' => :PUBLIC, 'RESERVED' => :RESERVED, 'REPLACED_BY' => :REPLACED_BY, 'SPLIT_FROM' => :SPLIT_FROM, 'MERGED_TO' => :MERGED_TO, 'REJECT' => :REJECT }
Instance Attribute Summary collapse
-
#assigner ⇒ String
readonly
The assigner's email address.
-
#date_assigned ⇒ DateTime?
readonly
Date assigned.
-
#date_public ⇒ DateTime?
readonly
Date published publically.
-
#date_requested ⇒ DateTime?
readonly
Date requested.
-
#id ⇒ ID
readonly
The CVE ID.
-
#replaced_by ⇒ Array<ID>?
readonly
List of IDs that replaced the CVE.
-
#requester ⇒ String?
readonly
Requester email address.
- #serial ⇒ Integer? readonly
- #state ⇒ :PUBLIC, ... readonly
- #title ⇒ String? readonly
-
#updated ⇒ DateTime?
readonly
Date last updated.
Class Method Summary collapse
-
.from_json(json) ⇒ Hash{Symbol => Object}
Maps the parsed JSON to a Symbol Hash for #initialize.
-
.load(json) ⇒ self
Loads the data-meta object from the parsed JSON.
Instance Method Summary collapse
-
#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) ⇒ DataMeta
constructor
Initializes the data-meta object.
Constructor Details
#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) ⇒ DataMeta
Initializes the data-meta object.
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 |
# 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 |
Instance Attribute Details
#assigner ⇒ String (readonly)
The assigner's email address.
22 23 24 |
# File 'lib/cve_schema/cve/data_meta.rb', line 22 def assigner @assigner end |
#date_assigned ⇒ DateTime? (readonly)
Date assigned.
40 41 42 |
# File 'lib/cve_schema/cve/data_meta.rb', line 40 def date_assigned @date_assigned end |
#date_public ⇒ DateTime? (readonly)
Date published publically.
45 46 47 |
# File 'lib/cve_schema/cve/data_meta.rb', line 45 def date_public @date_public end |
#date_requested ⇒ DateTime? (readonly)
Date requested.
35 36 37 |
# File 'lib/cve_schema/cve/data_meta.rb', line 35 def date_requested @date_requested end |
#id ⇒ ID (readonly)
The CVE ID.
17 18 19 |
# File 'lib/cve_schema/cve/data_meta.rb', line 17 def id @id end |
#replaced_by ⇒ Array<ID>? (readonly)
List of IDs that replaced the CVE.
55 56 57 |
# File 'lib/cve_schema/cve/data_meta.rb', line 55 def replaced_by @replaced_by end |
#requester ⇒ String? (readonly)
Requester email address.
50 51 52 |
# File 'lib/cve_schema/cve/data_meta.rb', line 50 def requester @requester end |
#serial ⇒ Integer? (readonly)
30 31 32 |
# File 'lib/cve_schema/cve/data_meta.rb', line 30 def serial @serial end |
#state ⇒ :PUBLIC, ... (readonly)
67 68 69 |
# File 'lib/cve_schema/cve/data_meta.rb', line 67 def state @state end |
#title ⇒ String? (readonly)
70 71 72 |
# File 'lib/cve_schema/cve/data_meta.rb', line 70 def title @title end |
#updated ⇒ DateTime? (readonly)
Date last updated.
27 28 29 |
# File 'lib/cve_schema/cve/data_meta.rb', line 27 def updated @updated end |
Class Method Details
.from_json(json) ⇒ Hash{Symbol => Object}
Maps the parsed JSON to a Symbol Hash for #initialize.
136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 |
# 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) ⇒ self
Loads the data-meta object from the parsed JSON.
179 180 181 |
# File 'lib/cve_schema/cve/data_meta.rb', line 179 def self.load(json) new(**from_json(json)) end |