cvss-suite 3.2.1 → 3.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c13e3d336237b452f735f78972b31520c80115b7451bf81287f72a3b4b76d65a
4
- data.tar.gz: fbbc06267f44b3ae4ddbafe5c0c3c2a50eeecec08dd95c1a3edb20ec15765307
3
+ metadata.gz: 773b87ded42d73797271e4dd4c05a261b69bc957295fe75654084f4edf4a4521
4
+ data.tar.gz: e5ecc4e25e13cc8663ca12cbb8b065246ee25b0e44fbfb6bfdbbfdb61ef16b61
5
5
  SHA512:
6
- metadata.gz: 7a4255bb0a792743a9013763620a5c93d3530ebbbd760d915f20569693ec85ff3cd44744b5aa19ef356fd6555fec935c4f8191d2844e61ee533662094379090f
7
- data.tar.gz: aa99f6949546a68d0145a7a964d8188ca07fd8c6cde4b8d9df6fa1d324410f2ca3a98c3c38e875f44d84b388a0ee6f5e33ca1db0deab1447c7da325d9dc9654a
6
+ metadata.gz: 3538af971b672a09547bc6f1286714876c7fe4ee61d19d4fddfaf961c42b014040cabd4259c0e22cb177064109d877a7339101ff7258afeb1b3ed937ed3cc516
7
+ data.tar.gz: 8b3ffb3367ee5437b1ee0026ca7f1677da233c844124455886c580cb2cedc5cd0b72c712a920741dc942600fc58a99c4f88f3c6c3b23ae750c962e6cc3ba1907
data/.rspec CHANGED
@@ -1,2 +1,3 @@
1
1
  --format documentation
2
2
  --color
3
+ --warning
data/CHANGES.md CHANGED
@@ -2,6 +2,14 @@
2
2
  All notable changes to this project will be documented in this file.
3
3
  This project adheres to [Semantic Versioning](http://semver.org/).
4
4
 
5
+ ## [3.2.2] - 2024-08-04
6
+
7
+ ### Fixes
8
+ * Add extra CVSS vector validations for 3.1 and lower. Fixes [#41](https://github.com/0llirocks/cvss-suite/issues/41)
9
+
10
+ ### Notes
11
+ * An invalid value like E:R (R doesn't exists) now counts as invalid, resulting in an invalid vector. In <= 3.2.1 an invalid value would be ignored/counted as default value.
12
+
5
13
  ## [3.2.1] - 2024-05-25
6
14
 
7
15
  ### Fixes
data/CODE_OF_CONDUCT.md CHANGED
@@ -1,17 +1,5 @@
1
1
  CVSS-Suite, a Ruby gem to manage the CVSS vector
2
2
 
3
- Copyright (c) 2016-2022 Siemens AG
4
- Copyright (c) 2022-2024 0llirocks
5
-
6
- Author: 0llirocks <https://github.com/0llirocks>
7
-
8
- Contributors:
9
- Florian Wininger <https://github.com/fwininger>
10
- Adam David <https://github.com/adamrdavid>
11
- Alexandre Zanni <https://github.com/noraj>
12
- joePedantic <https://github.com/joePedantic>
13
- Brandyn Phelps <https://github.com/brphelps>
14
-
15
3
  This work is licensed under the terms of the MIT license.
16
4
  See the LICENSE.md file in the top-level directory.
17
5
 
data/LICENSE.md CHANGED
@@ -1,16 +1,17 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2016-2022 Siemens AG
3
+ Copyright (c) 2016-2022 Siemens AG\
4
4
  Copyright (c) 2022-2024 0llirocks
5
5
 
6
- Authors:
7
- 0llirocks <https://github.com/0llirocks>
6
+ Author: 0llirocks <https://github.com/0llirocks>
7
+
8
8
  Contributors:
9
- Florian Wininger <https://github.com/fwininger>
10
- Adam David <https://github.com/adamrdavid>
11
- Alexandre Zanni <https://github.com/noraj>
12
- joePedantic <https://github.com/joePedantic>
13
- Brandyn Phelps <https://github.com/brphelps>
9
+ - Florian Wininger <https://github.com/fwininger>
10
+ - Adam David <https://github.com/adamrdavid>
11
+ - Alexandre Zanni <https://github.com/noraj>
12
+ - joePedantic <https://github.com/joePedantic>
13
+ - Brandyn Phelps <https://github.com/brphelps>
14
+ - Karim ElGhandour <https://github.com/kghandour>
14
15
 
15
16
  Permission is hereby granted, free of charge, to any person obtaining a copy of
16
17
  this software and associated documentation files (the "Software"), to deal in
@@ -351,7 +351,7 @@ module CvssSuite
351
351
  end
352
352
 
353
353
  def concat_and_stringify(first, second, third, fourth, fifth, sixth)
354
- ''.concat(first.to_s, second.to_s, third.to_s, fourth.to_s, fifth.to_s, sixth.to_s)
354
+ String.new.concat(first.to_s, second.to_s, third.to_s, fourth.to_s, fifth.to_s, sixth.to_s)
355
355
  end
356
356
 
357
357
  def sum_or_nil(values)
@@ -27,11 +27,10 @@ module CvssSuite
27
27
  # Returns if CVSS vector is valid.
28
28
  def valid?
29
29
  if @amount_of_properties >= required_amount_of_properties
30
- base = @base.valid?
31
- temporal = @base.valid? && @temporal&.valid?
32
- environmental = @base.valid? && @environmental&.valid?
33
- full = @base.valid? && @temporal&.valid? && @environmental&.valid?
34
- base || temporal || environmental || full
30
+ entered_keys = @properties.collect { |p| p[:name] }
31
+ return false if (entered_keys - allowed_abbreviations).size.positive?
32
+
33
+ check_metrics_validity
35
34
  else
36
35
  false
37
36
  end
@@ -46,5 +45,17 @@ module CvssSuite
46
45
 
47
46
  base_score
48
47
  end
48
+
49
+ private
50
+
51
+ def allowed_abbreviations
52
+ @base.properties.collect(&:abbreviation) +
53
+ @temporal.properties.collect(&:abbreviation) +
54
+ @environmental.properties.collect(&:abbreviation)
55
+ end
56
+
57
+ def check_metrics_validity
58
+ @base.valid? && @temporal&.valid? && @environmental&.valid?
59
+ end
49
60
  end
50
61
  end
@@ -41,5 +41,11 @@ module CvssSuite
41
41
 
42
42
  @all_up.score
43
43
  end
44
+
45
+ ##
46
+ # Alias for overall_score.
47
+ def score
48
+ overall_score
49
+ end
44
50
  end
45
51
  end
@@ -44,7 +44,7 @@ module CvssSuite
44
44
  end
45
45
  property&.set_selected_value selected_property[:selected]
46
46
  end
47
- @properties.reject(&:valid?).each(&:set_default_value)
47
+ @properties.select(&:non_selected?).each(&:set_default_value)
48
48
  end
49
49
  end
50
50
  end
@@ -58,7 +58,7 @@ module CvssSuite
58
58
  # Returns true if the property is valid.
59
59
 
60
60
  def valid?
61
- !@selected_value.nil?
61
+ !@selected_value.nil? && @property[:values].map { |p| p[:abbreviation] }.include?(@selected_value[:abbreviation])
62
62
  end
63
63
 
64
64
  ##
@@ -76,6 +76,9 @@ module CvssSuite
76
76
  value[:selected] = selected_value.eql?(value[:abbreviation])
77
77
  end
78
78
  @selected_value = values.detect { |value| value[:selected] }
79
+ return unless @selected_value.nil?
80
+
81
+ @selected_value = { abbreviation: selected_value }
79
82
  end
80
83
 
81
84
  ##
@@ -84,8 +87,16 @@ module CvssSuite
84
87
  def set_default_value
85
88
  values.each do |value|
86
89
  value[:selected] = value[:abbreviation].eql?('X')
90
+ value[:selected] ||= value[:abbreviation].eql?('ND')
87
91
  end
88
92
  @selected_value = values.detect { |value| value[:selected] }
89
93
  end
94
+
95
+ ##
96
+ # Returns whether a selected_value is set
97
+
98
+ def non_selected?
99
+ @selected_value.nil?
100
+ end
90
101
  end
91
102
  end
@@ -4,5 +4,5 @@
4
4
  # See the LICENSE.md file in the top-level directory.
5
5
 
6
6
  module CvssSuite
7
- VERSION = '3.2.1'.freeze
7
+ VERSION = '3.3.0'.freeze
8
8
  end
data/lib/cvss_suite.rb CHANGED
@@ -27,7 +27,12 @@ module CvssSuite
27
27
  def self.new(vector)
28
28
  return InvalidCvss.new unless vector.is_a? String
29
29
 
30
- @vector_string = vector
30
+ @vector_string = if vector.frozen?
31
+ vector.dup
32
+ else
33
+ vector
34
+ end
35
+
31
36
  case version
32
37
  when 2
33
38
  Cvss2.new(prepare_vector(@vector_string))
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: 3.2.1
4
+ version: 3.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - 0llirocks
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-05-25 00:00:00.000000000 Z
11
+ date: 2024-08-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -150,7 +150,7 @@ licenses:
150
150
  metadata:
151
151
  bug_tracker_uri: https://github.com/0llirocks/cvss-suite/issues
152
152
  changelog_uri: https://github.com/0llirocks/cvss-suite/blob/master/CHANGES.md
153
- documentation_uri: https://www.rubydoc.info/gems/cvss-suite/3.2.1
153
+ documentation_uri: https://www.rubydoc.info/gems/cvss-suite/3.3.0
154
154
  homepage_uri: https://cvss-suite.0lli.rocks
155
155
  source_code_uri: https://github.com/0llirocks/cvss-suite
156
156
  post_install_message: