Class: CVESchema::CVE::Impact
- Inherits:
-
Object
- Object
- CVESchema::CVE::Impact
- Defined in:
- lib/cve_schema/cve/impact.rb,
lib/cve_schema/cve/impact/cvss_v2.rb,
lib/cve_schema/cve/impact/cvss_v3.rb
Defined Under Namespace
Instance Attribute Summary collapse
- #cvssv2 ⇒ CVSSv2? (also: #cvss_v2) readonly
- #cvssv3 ⇒ CVSSv3? (also: #cvss_v3) readonly
Class Method Summary collapse
-
.from_json(json) ⇒ Hash{Symbol => Object}
Maps the parsed JSON to a Symbol Hash for #initialize.
-
.load(json) ⇒ Impact
Loads the impact object from the parsed JSON.
Instance Method Summary collapse
-
#initialize(cvssv2: nil, cvssv3: nil) ⇒ Impact
constructor
Initializes the impact object.
Constructor Details
#initialize(cvssv2: nil, cvssv3: nil) ⇒ Impact
Initializes the impact object.
27 28 29 30 |
# File 'lib/cve_schema/cve/impact.rb', line 27 def initialize(cvssv2: nil, cvssv3: nil) @cvssv2 = cvssv2 @cvssv3 = cvssv3 end |
Instance Attribute Details
#cvssv2 ⇒ CVSSv2? (readonly) Also known as: cvss_v2
9 10 11 |
# File 'lib/cve_schema/cve/impact.rb', line 9 def cvssv2 @cvssv2 end |
#cvssv3 ⇒ CVSSv3? (readonly) Also known as: cvss_v3
14 15 16 |
# File 'lib/cve_schema/cve/impact.rb', line 14 def cvssv3 @cvssv3 end |
Class Method Details
.from_json(json) ⇒ Hash{Symbol => Object}
Maps the parsed JSON to a Symbol Hash for #initialize.
43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/cve_schema/cve/impact.rb', line 43 def self.from_json(json) # HACK: the "impact" value is often an Array containing a single Hash hash = case json when Hash then json when Array then json[0] else raise(InvalidJSON,'"impact" is neither a Hash or Array') end { cvssv2: hash['cvssv2'] && CVSSv2.load(hash['cvssv2']), cvssv3: hash['cvssv3'] && CVSSv3.load(hash['cvssv3']) } end |
.load(json) ⇒ Impact
Loads the impact object from the parsed JSON.
69 70 71 |
# File 'lib/cve_schema/cve/impact.rb', line 69 def self.load(json) new(**from_json(json)) end |