Class: CvssSuite::CvssMetric

Inherits:
Object
  • Object
show all
Defined in:
lib/cvss_suite/cvss_metric.rb

Overview

This class represents any CVSS metric.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(selected_properties) ⇒ CvssMetric

Creates a new CVSS metric by properties



12
13
14
15
16
# File 'lib/cvss_suite/cvss_metric.rb', line 12

def initialize(selected_properties)
  @properties = []
  init_properties
  extract_selected_values_from selected_properties
end

Instance Attribute Details

#propertiesObject (readonly)

We aggregate these in some other classes



46
47
48
# File 'lib/cvss_suite/cvss_metric.rb', line 46

def properties
  @properties
end

Instance Method Details

#countObject

Returns number of properties for this metric.



40
41
42
# File 'lib/cvss_suite/cvss_metric.rb', line 40

def count
  @properties.count
end

#explicitly_provided?Boolean

Returns if any property in this metric was explicitly provided (i.e., set to a value other than the default ‘X’ or ‘ND’).

Returns:

  • (Boolean)


30
31
32
33
34
35
36
# File 'lib/cvss_suite/cvss_metric.rb', line 30

def explicitly_provided?
  @properties.any? do |property|
    property.valid? &&
      property.selected_value[:abbreviation] != 'X' &&
      property.selected_value[:abbreviation] != 'ND'
  end
end

#valid?Boolean

Returns if the metric is valid.

Returns:

  • (Boolean)


20
21
22
23
24
25
# File 'lib/cvss_suite/cvss_metric.rb', line 20

def valid?
  @properties.each do |property|
    return false unless property.valid?
  end
  true
end