cvss-suite 1.2.2 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -8,21 +8,20 @@
8
8
  # This work is licensed under the terms of the MIT license.
9
9
  # See the LICENSE.md file in the top-level directory.
10
10
 
11
- ##
12
- # This class represents a CVSS property of a CVSS metric.
13
-
14
11
  module CvssSuite
12
+ ##
13
+ # This class represents a CVSS property of a CVSS metric.
15
14
  class CvssProperty
16
15
  ##
17
16
  # Creates a new CVSS property by a +property+.
18
17
  #
19
18
  # +Property+ needs to consist of a name, a abbreviation,
20
19
  # the possible positions in the CVSS vector, a weight, and the
21
- # available choices for the property.
20
+ # available values for the property.
22
21
 
23
22
  def initialize(property)
24
23
  @property = property
25
- @property[:default_choice] ||= 'Not Available'
24
+ @property[:default_value] ||= 'Not Available'
26
25
  end
27
26
 
28
27
  ##
@@ -40,10 +39,10 @@ module CvssSuite
40
39
  end
41
40
 
42
41
  ##
43
- # Returns all available choices of the property.
42
+ # Returns all available values of the property.
44
43
 
45
- def choices
46
- @property[:choices]
44
+ def values
45
+ @property[:values]
47
46
  end
48
47
 
49
48
  ##
@@ -54,34 +53,34 @@ module CvssSuite
54
53
  end
55
54
 
56
55
  ##
57
- # Returns the selected choice of the property.
56
+ # Returns the selected value of the property.
58
57
 
59
- def selected_choice
60
- @selected_choice || @property[:default_choice]
58
+ def selected_value
59
+ @selected_value || @property[:default_value]
61
60
  end
62
61
 
63
62
  ##
64
63
  # Returns true if the property is valid.
65
64
 
66
65
  def valid?
67
- !@selected_choice.nil?
66
+ !@selected_value.nil?
68
67
  end
69
68
 
70
69
  ##
71
- # Returns the score of the selected choice.
70
+ # Returns the score of the selected value.
72
71
 
73
72
  def score
74
- @selected_choice[:weight]
73
+ @selected_value[:weight]
75
74
  end
76
75
 
77
76
  ##
78
- # Sets the selected choice by a +choice+.
77
+ # Sets the selected value by a +value+.
79
78
 
80
- def set_selected_choice(selected_choice)
81
- choices.each do |choice|
82
- choice[:selected] = selected_choice.eql?(choice[:abbreviation])
79
+ def set_selected_value(selected_value)
80
+ values.each do |value|
81
+ value[:selected] = selected_value.eql?(value[:abbreviation])
83
82
  end
84
- @selected_choice = choices.detect { |choice| choice[:selected] }
83
+ @selected_value = values.detect { |value| value[:selected] }
85
84
  end
86
85
  end
87
86
  end
@@ -8,10 +8,9 @@
8
8
  # This work is licensed under the terms of the MIT license.
9
9
  # See the LICENSE.md file in the top-level directory.
10
10
 
11
- ##
12
- # This module includes methods which are used by the CVSS 3 classes.
13
-
14
11
  module CvssSuite
12
+ ##
13
+ # This module includes methods which are used by the CVSS 3 classes.
15
14
  module Cvss3Helper
16
15
  ##
17
16
  # Since CVSS 3 all float values are rounded up, therefore this method is used
@@ -21,14 +20,14 @@ module CvssSuite
21
20
  end
22
21
 
23
22
  ##
24
- # Since CVSS 3 the Privilege Required score depends on the selected choice of the Scope metric.
23
+ # Since CVSS 3 the Privilege Required score depends on the selected value of the Scope metric.
25
24
  # This method takes a +Privilege+ +Required+ and a +Scope+ metric and returns the newly calculated score.
26
25
  def self.privileges_required_score(privileges_required, scope)
27
- changed = scope.selected_choice[:name] == 'Changed'
26
+ changed = scope.selected_value[:name] == 'Changed'
28
27
  privilege_score = privileges_required.score
29
28
  if changed
30
- privilege_score = 0.68 if privileges_required.selected_choice[:name] == 'Low'
31
- privilege_score = 0.50 if privileges_required.selected_choice[:name] == 'High'
29
+ privilege_score = 0.68 if privileges_required.selected_value[:name] == 'Low'
30
+ privilege_score = 0.50 if privileges_required.selected_value[:name] == 'High'
32
31
  end
33
32
  privilege_score
34
33
  end
@@ -8,47 +8,40 @@
8
8
  # This work is licensed under the terms of the MIT license.
9
9
  # See the LICENSE.md file in the top-level directory.
10
10
 
11
- # ##
12
- # # This class represents a invalid CVSS vector.
13
-
14
11
  module CvssSuite
12
+ ##
13
+ # This class represents a invalid CVSS vector.
15
14
  class InvalidCvss < Cvss
16
15
  ##
17
16
  # Creates a new invalid CVSS vector.
18
-
19
17
  def initialize; end
20
18
 
21
19
  ##
22
20
  # Since this is an invalid CVSS vector, it always returns false.
23
-
24
21
  def valid?
25
22
  false
26
23
  end
27
24
 
28
25
  ##
29
26
  # Since this is an invalid CVSS vector, it always throws an exception.
30
-
31
27
  def version
32
28
  check_validity
33
29
  end
34
30
 
35
31
  ##
36
32
  # Since this is an invalid CVSS vector, it always throws an exception.
37
-
38
33
  def base_score
39
34
  check_validity
40
35
  end
41
36
 
42
37
  ##
43
38
  # Since this is an invalid CVSS vector, it always throws an exception.
44
-
45
39
  def temporal_score
46
40
  check_validity
47
41
  end
48
42
 
49
43
  ##
50
44
  # Since this is an invalid CVSS vector, it always throws an exception.
51
-
52
45
  def environmental_score
53
46
  check_validity
54
47
  end
@@ -9,5 +9,5 @@
9
9
  # See the LICENSE.md file in the top-level directory.
10
10
 
11
11
  module CvssSuite
12
- VERSION = '1.2.2'
12
+ VERSION = '2.0.0'.freeze
13
13
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cvss-suite
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.2
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Oliver Hamboerger
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-07-19 00:00:00.000000000 Z
11
+ date: 2020-05-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -79,6 +79,7 @@ files:
79
79
  - ".github/ISSUE_TEMPLATE/custom.md"
80
80
  - ".github/ISSUE_TEMPLATE/feature_request.md"
81
81
  - ".github/workflows/rspec.yml"
82
+ - ".github/workflows/rubocop.yml"
82
83
  - ".gitignore"
83
84
  - ".rspec"
84
85
  - ".rubocop.yml"
@@ -126,7 +127,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
126
127
  requirements:
127
128
  - - ">="
128
129
  - !ruby/object:Gem::Version
129
- version: 2.0.0
130
+ version: 2.4.0
130
131
  required_rubygems_version: !ruby/object:Gem::Requirement
131
132
  requirements:
132
133
  - - ">="