class CVESchema::CVE::Source

Represents the `“source”` JSON object.

Constants

DISCOVERY

Attributes

advisory[R]

@return [String, nil]

defect[R]

@return [Array<String>, nil]

discovery[R]

@return [:INTERNAL, :EXTERNAL, :USER, :UNKNOWN]

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 mapped Symbol Hash.
# File lib/cve_schema/cve/source.rb, line 50
def self.from_json(json)
  {
    defect:    json['defect'],
    discovery: DISCOVERY[json['discovery']],
    advisory:  json['advisory']
  }
end
load(json) click to toggle source

Loads the source from the parsed JSON.

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

The parsed JSON.

@return [Source]

The loaded source object.

@api semipublic

# File lib/cve_schema/cve/source.rb, line 69
def self.load(json)
  new(**from_json(json))
end
new(discovery: , defect: nil, advisory: nil) click to toggle source

Initializes the source object.

@param [Array<String>, nil] defect

@param [:INTERNAL, :EXTERNAL, :USER, :UNKNOWN] discovery

@param [String, nil] advisory

# File lib/cve_schema/cve/source.rb, line 35
def initialize(discovery: , defect: nil, advisory: nil)
  @defect    = defect
  @discovery = discovery
  @advisory  = advisory
end