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



14
15
16
17
18
# File 'lib/cvss_suite/cvss_metric.rb', line 14

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



48
49
50
# File 'lib/cvss_suite/cvss_metric.rb', line 48

def properties
  @properties
end

Instance Method Details

#countObject

Returns number of properties for this metric.



42
43
44
# File 'lib/cvss_suite/cvss_metric.rb', line 42

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)


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

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)


22
23
24
25
26
27
# File 'lib/cvss_suite/cvss_metric.rb', line 22

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