Class: CVESchema::CVE
- Inherits:
-
Object
show all
- Defined in:
- lib/cve_schema/cve.rb,
lib/cve_schema/cve/id.rb,
lib/cve_schema/cve/na.rb,
lib/cve_schema/cve/credit.rb,
lib/cve_schema/cve/impact.rb,
lib/cve_schema/cve/source.rb,
lib/cve_schema/cve/vendor.rb,
lib/cve_schema/cve/affects.rb,
lib/cve_schema/cve/exploit.rb,
lib/cve_schema/cve/product.rb,
lib/cve_schema/cve/version.rb,
lib/cve_schema/cve/solution.rb,
lib/cve_schema/cve/timeline.rb,
lib/cve_schema/cve/data_meta.rb,
lib/cve_schema/cve/reference.rb,
lib/cve_schema/cve/timestamp.rb,
lib/cve_schema/cve/description.rb,
lib/cve_schema/cve/work_around.rb,
lib/cve_schema/cve/problem_type.rb,
lib/cve_schema/cve/configuration.rb,
lib/cve_schema/cve/has_lang_value.rb,
lib/cve_schema/cve/impact/cvss_v2.rb,
lib/cve_schema/cve/impact/cvss_v3.rb
Overview
Represents a "cve"
JSON object.
Defined Under Namespace
Modules: HasLangValue, Timestamp
Classes: Affects, Configuration, Credit, DataMeta, Description, Exploit, ID, Impact, ProblemType, Product, Reference, Solution, Source, Timeline, Vendor, Version, WorkAround
Constant Summary
collapse
- DATA_TYPES =
{
'CVE' => :CVE,
'CNA' => :CNA,
'CVEMENTOR' => :CVEMENTOR
}
- DATA_FORMAT =
{
'MITRE' => :MITRE
}
- DATA_VERSIONS =
{
'4.0' => :"4.0"
}
- NA =
'n/a'
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
-
#initialize(data_type:, data_format:, data_version:, data_meta:, affects: nil, configuration: [], problemtype: [], references: [], description: [], exploit: [], credit: [], impact: nil, solution: [], source: nil, work_around: [], timeline: []) ⇒ CVE
constructor
Constructor Details
#initialize(data_type:, data_format:, data_version:, data_meta:, affects: nil, configuration: [], problemtype: [], references: [], description: [], exploit: [], credit: [], impact: nil, solution: [], source: nil, work_around: [], timeline: []) ⇒ CVE
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
|
# File 'lib/cve_schema/cve.rb', line 140
def initialize(data_type: , data_format: , data_version: , data_meta: ,
affects: nil,
configuration: [],
problemtype: [],
references: [],
description: [],
exploit: [],
credit: [],
impact: nil,
solution: [],
source: nil,
work_around: [],
timeline: []
)
@data_type = data_type
@data_format = data_format
@data_version = data_version
@data_meta = data_meta
@affects = affects
@configuration = configuration
@problemtype = problemtype
@references = references
@description = description
@exploit = exploit
@credit = credit
@impact = impact
@solution = solution
@source = source
@work_around = work_around
@timeline = timeline
end
|
Instance Attribute Details
53
54
55
|
# File 'lib/cve_schema/cve.rb', line 53
def affects
@affects
end
|
#configuration ⇒ Array<Configuration>
Also known as:
configurations
56
57
58
|
# File 'lib/cve_schema/cve.rb', line 56
def configuration
@configuration
end
|
#credit ⇒ Array<Credit>
Also known as:
credits
80
81
82
|
# File 'lib/cve_schema/cve.rb', line 80
def credit
@credit
end
|
38
39
40
|
# File 'lib/cve_schema/cve.rb', line 38
def data_format
@data_format
end
|
48
49
50
|
# File 'lib/cve_schema/cve.rb', line 48
def data_meta
@data_meta
end
|
#data_type ⇒ :CVE, ...
31
32
33
|
# File 'lib/cve_schema/cve.rb', line 31
def data_type
@data_type
end
|
#data_version ⇒ :"4.0"
45
46
47
|
# File 'lib/cve_schema/cve.rb', line 45
def data_version
@data_version
end
|
#description ⇒ Array<Description>
Also known as:
descriptions
70
71
72
|
# File 'lib/cve_schema/cve.rb', line 70
def description
@description
end
|
#exploit ⇒ Array<Exploit>
Also known as:
exploits
75
76
77
|
# File 'lib/cve_schema/cve.rb', line 75
def exploit
@exploit
end
|
85
86
87
|
# File 'lib/cve_schema/cve.rb', line 85
def impact
@impact
end
|
#problemtype ⇒ ProblemType
Also known as:
problem_type, problem_types
61
62
63
|
# File 'lib/cve_schema/cve.rb', line 61
def problemtype
@problemtype
end
|
#references ⇒ Array<Reference>
67
68
69
|
# File 'lib/cve_schema/cve.rb', line 67
def references
@references
end
|
#solution ⇒ Array<Solution>
Also known as:
solutions
88
89
90
|
# File 'lib/cve_schema/cve.rb', line 88
def solution
@solution
end
|
93
94
95
|
# File 'lib/cve_schema/cve.rb', line 93
def source
@source
end
|
#timeline ⇒ Array<Timeline>
101
102
103
|
# File 'lib/cve_schema/cve.rb', line 101
def timeline
@timeline
end
|
#work_around ⇒ Array<WorkAround>
Also known as:
work_arounds
96
97
98
|
# File 'lib/cve_schema/cve.rb', line 96
def work_around
@work_around
end
|
Class Method Details
.from_json(json) ⇒ Hash{Symbol => Object}
Maps the JSON Hash into a Symbols Hash for #initialize.
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
|
# File 'lib/cve_schema/cve.rb', line 188
def self.from_json(json)
{
data_type: if (data_type = json['data_type'])
DATA_TYPES.fetch(data_type) do
raise UnknownJSONValue.new('data_type',data_type)
end
else
raise MissingJSONKey.new('data_type')
end,
data_format: if (data_format = json['data_format'])
DATA_FORMAT.fetch(data_format) do
raise UnknownJSONValue.new('data_format',data_format)
end
else
raise MissingJSONKey.new('data_format')
end,
data_version: if (data_version = json['data_version'])
DATA_VERSIONS.fetch(data_version) do
raise UnknownJSONValue.new('data_version',data_version)
end
else
raise MissingJSONKey.new('data_version')
end,
data_meta: if (cve_data_meta = json['CVE_data_meta'])
DataMeta.load(cve_data_meta)
else
raise MissingJSONKey.new('CVE_data_meta')
end,
affects: json['affects'] && Affects.load(json['affects']),
configuration: Array(json['configuration']).map(&Configuration.method(:load)),
problemtype: Array(json['problemtype'] && json['problemtype']['problemtype_data']).map(&ProblemType.method(:load)),
references: Array(json['references'] && json['references']['reference_data']).map(&Reference.method(:load)),
description: Array(json['description'] && json['description']['description_data']).map(&Description.method(:load)),
exploit: Array(json['exploit']).map(&Exploit.method(:load)),
credit: Array(json['credit']).map(&Credit.method(:load)),
impact: json['impact'] && Impact.load(json['impact']),
solution: Array(json['solution']).map(&Solution.method(:load)),
source: json['source'] && Source.load(json['source']),
work_around: Array(json['work_around']).map(&WorkAround.method(:load)),
timeline: Array(json['timeline']).map(&Timeline.method(:load))
}
end
|
.load(json) ⇒ self
Loads the CVE data from parsed JSON.
252
253
254
|
# File 'lib/cve_schema/cve.rb', line 252
def self.load(json)
new(**from_json(json))
end
|