Sha256: e3ae465afe90730ab34d09314f7366aacd4e994947af0ad9da33ba7086068410
Contents?: true
Size: 1.78 KB
Versions: 3
Compression:
Stored size: 1.78 KB
Contents
# CVSS-Suite, a Ruby gem to manage the CVSS vector # # Copyright (c) Siemens AG, 2016 # # Authors: # Oliver Hambörger <oliver.hamboerger@siemens.com> # # This work is licensed under the terms of the MIT license. # See the LICENSE.md file in the top-level directory. module CvssSuite ## # This class represents a CVSS property of a CVSS metric. class CvssProperty ## # Creates a new CVSS property by a +property+. # # +Property+ needs to consist of a name, a abbreviation, # the possible positions in the CVSS vector, a weight, and the # available values for the property. def initialize(property) @property = property @property[:default_value] ||= 'Not Available' end ## # Returns the full name of the property. def name @property[:name] end ## # Returns the abbreviation of the property. def abbreviation @property[:abbreviation] end ## # Returns all available values of the property. def values @property[:values] end ## # Returns the possible positions in the CVSS vector of the property. def position @property[:position] end ## # Returns the selected value of the property. def selected_value @selected_value || @property[:default_value] end ## # Returns true if the property is valid. def valid? !@selected_value.nil? end ## # Returns the score of the selected value. def score @selected_value[:weight] end ## # Sets the selected value by a +value+. def set_selected_value(selected_value) values.each do |value| value[:selected] = selected_value.eql?(value[:abbreviation]) end @selected_value = values.detect { |value| value[:selected] } end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
cvss-suite-2.0.2 | lib/cvss_suite/cvss_property.rb |
cvss-suite-2.0.1 | lib/cvss_suite/cvss_property.rb |
cvss-suite-2.0.0 | lib/cvss_suite/cvss_property.rb |