class CVESchema::CVE
Represents a `“cve”` JSON object.
Constants
- DATA_FORMAT
- DATA_TYPES
- DATA_VERSIONS
- NA
The `n/a` constant.
Attributes
@return [Affects, nil]
@return [Array<Configuration>]
@return [Array<Configuration>]
@return [Array<Credit>]
@return [Array<Credit>]
@return [:MITRE]
@return [DataMeta]
@return [:CVE, :CNA, :CVEMENTOR]
@return [:“4.0”]
@return [Array<Description>]
@return [Array<Description>]
@return [Array<Exploit>]
@return [Array<Exploit>]
@return [Impact, nil]
@return [DataMeta]
@return [ProblemType]
@return [ProblemType]
@return [ProblemType]
@return [Array<Reference>]
@return [Array<Solution>]
@return [Array<Solution>]
@return [Source, nil]
@return [Array<Timeline>]
@return [Array<WorkAround>]
@return [Array<WorkAround>]
Public Class Methods
Maps the JSON Hash into a Symbols Hash for {#initialize}.
@param [Hash{String => Object}] json
The parsed JSON.
@return [Hash{Symbol => Object}]
The maped Symbol Hash.
@raise [MissingJSONKey]
The `"data_type"`, `"data_format"`, `"data_version"`, or `"CVE_data_key"` JSON keys were missing.
@api semipublic
# 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
Loads the CVE
data from parsed JSON.
@param [Hash{String => Object}] json
The parsed JSON.
@return [self]
@raise [MissingJSONKey]
The `"data_type"`, `"data_format"`, `"data_version"`, or `"CVE_data_key"` JSON keys were missing.
@api public
# File lib/cve_schema/cve.rb, line 252 def self.load(json) new(**from_json(json)) end
Initializes the CVE
.
@param [:CVE, :CNA, :CVEMENTOR] data_type
@param [:MITRE] data_format
@param [:“4.0”] data_version
@param [DataMeta] data_meta
@param [Affects, nil] affects
@param [Array<Configuration>] configuration
@param [ArrayProblemType>] problemtype
@param [Array<Reference>] references
@param [Array<Description>] description
@param [Array<Exploit>] exploit
@param [Array<Credit>] credit
@param [Array<Impact>] impact
@param [Array<Solution>] solution
@param [Source, nil] source
@param [Array<WorkAround>] work_around
@param [Array<Timeline>] timeline
@api semipublic
# 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