cvss-suite 4.1.0 → 4.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 615e1ce401360d6127ec8a397b0d919b581588cbebe00d48fa1a8354d51397bc
4
- data.tar.gz: e8a8615c60983eae67971a2b86d465afc79be4ae5b0c0c099504b676f1a1e74c
3
+ metadata.gz: d8cf95b45495f191e7155aad10bebc43b092f5173fb65adcf4d7434b01bb9cd5
4
+ data.tar.gz: 7f3ffe1d5fc752d5f1da0b71bdb4211a0c538b8ce9f199328e93e83d640be594
5
5
  SHA512:
6
- metadata.gz: f68645079416546c5bb80e0a2ec0688a58e6889f9d334621130d563c882e90b735a9d2cad8bdf00c7e92c79b5d233e4bbca645d81347715dbacb25448addde30
7
- data.tar.gz: e4bf4cd7073062cc9a2504d6f4cda6485d7b187c22ec9928740b9af89a2a990baa220f54b3843931cb43d27b5851290ad18c2f4ddbfc350990c425a7b7c0df6a
6
+ metadata.gz: 6d8a171815a4b9037dcd791b557f4d225a93a7a82dd8d497d461ef74883e4d4c68243b746fac5da8a3db8aa7dafb92d821c34ccdba6d9b16386fe87f0e9c3d33
7
+ data.tar.gz: bc43b1151b310bbe245c09112e2911c344bffc8b62e3641be955139dcf4fb3021eb1093b008efad0f00b853959e521bd1c139c3ccd30947fe60899838386c7dd
data/.gitignore CHANGED
@@ -11,3 +11,4 @@
11
11
  .idea/
12
12
  /*.gem
13
13
  .ruby-version
14
+ .rspec_status
data/CHANGES.md CHANGED
@@ -2,10 +2,16 @@
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
+ ## [4.1.1] - 2025-05-11
6
+
7
+ ### Fixes
8
+
9
+ See [v4.1.1](https://github.com/0llirocks/cvss-suite/releases/tag/v4.1.1). (@jgarber-cisco)
10
+
5
11
  ## [4.1.0] - 2025-04-27
6
12
 
7
13
  ### Improvements
8
- * Expose impact and exploitability sub-scores. (@jgarber-cisco)
14
+ * Expose impact and exploitability sub-scores for CVSS 2 and CVSS 3.x. (@jgarber-cisco)
9
15
 
10
16
  ## [4.0.0] - 2024-08-31
11
17
 
data/README.md CHANGED
@@ -11,6 +11,9 @@
11
11
  This Ruby gem helps you to process the vector of the [**Common Vulnerability Scoring System**](https://www.first.org/cvss/specification-document).
12
12
  Besides calculating the Base, Temporal and Environmental Score, you are able to extract the selected option.
13
13
 
14
+ > [!IMPORTANT]
15
+ > This project could need some new maintainer(s). I am having less time and motivation to support this gem. Support for v4 was only possible with the help of the community and I am sure I will not implement any v4.x or v5.x support by myself. Since this gem is used in some projects I will not step down without any kind of support. If you are interested in CVSS and ruby, feel free to work on upcoming issues and let me ([@Ollirocks](https://github.com/0llirocks)) know if you are willing to become a maintainer. As of today there are only a very few issues each year but each new version of CVSS results in quite a lot of work. I am fine with staying the owner of this project until someone is willing to take over completely. I will not vanish from GitHub once and or all :smile: The same applies to the ruby gems account, I am willing to push new versions to rubygems.org until someone trustworthy is found to take over.
16
+
14
17
  ## Installation
15
18
 
16
19
  Add this line to your application's Gemfile:
data/cvss_suite.gemspec CHANGED
@@ -37,7 +37,10 @@ in version 4.0, 3.1, 3.0 and 2.'
37
37
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
38
38
  spec.require_paths = ['lib']
39
39
 
40
+ spec.add_dependency 'bigdecimal', '~> 3.1.8'
41
+
40
42
  spec.add_development_dependency 'bundler', '2.4.22'
43
+ spec.add_development_dependency 'csv', '~> 3.3'
41
44
  spec.add_development_dependency 'rspec', '~> 3.4'
42
45
  spec.add_development_dependency 'rspec-its', '~> 1.2'
43
46
  spec.add_development_dependency 'rubocop', '1.50.2'
@@ -3,6 +3,8 @@
3
3
  # This work is licensed under the terms of the MIT license.
4
4
  # See the LICENSE.md file in the top-level directory.
5
5
 
6
+ require 'bigdecimal/util'
7
+
6
8
  require_relative '../cvss_31_and_before'
7
9
  require_relative 'cvss2_base'
8
10
  require_relative 'cvss2_temporal'
@@ -18,12 +20,12 @@ module CvssSuite
18
20
  2
19
21
  end
20
22
 
21
- # Returns the severity of the CVSSv2 vector.
23
+ # Returns the severity of the CVSSv2 base score.
22
24
  # https://nvd.nist.gov/vuln-metrics/cvss
23
25
  def severity
24
26
  check_validity
25
27
 
26
- score = overall_score
28
+ score = base_score
27
29
 
28
30
  case score
29
31
  when 0.0..3.9
@@ -47,7 +49,7 @@ module CvssSuite
47
49
  ##
48
50
  # Returns the Temporal Score of the CVSS vector.
49
51
  def temporal_score
50
- (base_score * @temporal.score).round(1)
52
+ (base_score * @temporal.score.to_d).round(1).to_f
51
53
  end
52
54
 
53
55
  ##
@@ -31,11 +31,11 @@ module CvssSuite
31
31
  end
32
32
 
33
33
  def impact_subscore
34
- calc_impact.round(1)
34
+ calc_impact
35
35
  end
36
36
 
37
37
  def exploitability_subscore
38
- calc_exploitability.round(1)
38
+ calc_exploitability
39
39
  end
40
40
 
41
41
  private
@@ -78,7 +78,10 @@ module CvssSuite
78
78
  integrity_score = 1 - @integrity_impact.score * sr_ir_score
79
79
  availability_score = 1 - @availability_impact.score * sr_ar_score
80
80
 
81
- [10, 10.41 * (1 - confidentiality_score * integrity_score * availability_score)].min
81
+ impact = 10.41 * (1 - confidentiality_score * integrity_score * availability_score)
82
+ return impact if sr_cr_score == 1 && sr_ir_score == 1 && sr_ar_score == 1
83
+
84
+ [10, impact].min
82
85
  end
83
86
 
84
87
  def calc_exploitability
@@ -3,6 +3,8 @@
3
3
  # This work is licensed under the terms of the MIT license.
4
4
  # See the LICENSE.md file in the top-level directory.
5
5
 
6
+ require 'bigdecimal/util'
7
+
6
8
  require_relative '../cvss_property'
7
9
  require_relative '../cvss_metric'
8
10
 
@@ -22,7 +24,7 @@ module CvssSuite
22
24
  @security_requirements_ir.score,
23
25
  @security_requirements_ar.score).round(1)
24
26
 
25
- adjusted_temporal = (base_score * temporal_score).round(1)
27
+ adjusted_temporal = (base_score * temporal_score.to_d).round(1).to_f
26
28
  (adjusted_temporal + (10 - adjusted_temporal) * @collateral_damage_potential.score) * @target_distribution.score
27
29
  end
28
30
 
@@ -32,11 +32,11 @@ module CvssSuite
32
32
  end
33
33
 
34
34
  def impact_subscore
35
- calc_impact.round(1)
35
+ calc_impact
36
36
  end
37
37
 
38
38
  def exploitability_subscore
39
- calc_exploitability.round(1)
39
+ calc_exploitability
40
40
  end
41
41
 
42
42
  private
@@ -33,11 +33,11 @@ module CvssSuite
33
33
  end
34
34
 
35
35
  def impact_subscore
36
- calc_impact.round(1)
36
+ calc_impact
37
37
  end
38
38
 
39
39
  def exploitability_subscore
40
- calc_exploitability.round(1)
40
+ calc_exploitability
41
41
  end
42
42
 
43
43
  private
@@ -3,6 +3,8 @@ require_relative 'cvss40_constants_max_composed'
3
3
  require_relative 'cvss40_constants_max_severity'
4
4
  require_relative 'cvss40_constants_levels'
5
5
 
6
+ require 'bigdecimal/util'
7
+
6
8
  module CvssSuite
7
9
  # This class performs much of the score calculation logic for CVSS 4.0.
8
10
  # It is heavily ported from the m and scoring methods in https://github.com/FIRSTdotorg/cvss-v4-calculator/blob/ac71416d935ad2ac87cd107ff87024561ea954a7/app.js#L121
@@ -132,7 +134,7 @@ module CvssSuite
132
134
  # Exception for no impact on system (shortcut)
133
135
  return 0.0 if %w[VC VI VA SC SI SA].all? { |metric| m(metric) == 'N' }
134
136
 
135
- value = LOOKUP[macro_vector]
137
+ value = LOOKUP[macro_vector].to_d
136
138
 
137
139
  # 1. For each of the EQs:
138
140
  # a. The maximal scoring difference is determined as the difference
@@ -257,7 +259,7 @@ module CvssSuite
257
259
  break
258
260
  end
259
261
 
260
- current_severity_distance_eq1 = severity_distance_av + severity_distance_pr + severity_distance_ui
262
+ current_severity_distance_eq1 = (severity_distance_av.to_d + severity_distance_pr + severity_distance_ui).to_f
261
263
  current_severity_distance_eq2 = severity_distance_ac + severity_distance_at
262
264
  current_severity_distance_eq3eq6 = sum_or_nil([severity_distance_vc, severity_distance_vi, severity_distance_va,
263
265
  severity_distance_cr, severity_distance_ir, severity_distance_ar])
@@ -339,7 +341,7 @@ module CvssSuite
339
341
  value -= mean_distance
340
342
  value = 0.0 if value.negative?
341
343
  value = 10.0 if value > 10
342
- value.round(1)
344
+ value.round(1).to_f
343
345
  end
344
346
 
345
347
  def get_eq_maxes(lookup, eq_value)
@@ -4,5 +4,5 @@
4
4
  # See the LICENSE.md file in the top-level directory.
5
5
 
6
6
  module CvssSuite
7
- VERSION = '4.1.0'.freeze
7
+ VERSION = '4.1.1'.freeze
8
8
  end
metadata CHANGED
@@ -1,14 +1,28 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cvss-suite
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.1.0
4
+ version: 4.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - 0llirocks
8
8
  bindir: exe
9
9
  cert_chain: []
10
- date: 2025-04-27 00:00:00.000000000 Z
10
+ date: 2025-05-11 00:00:00.000000000 Z
11
11
  dependencies:
12
+ - !ruby/object:Gem::Dependency
13
+ name: bigdecimal
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - "~>"
17
+ - !ruby/object:Gem::Version
18
+ version: 3.1.8
19
+ type: :runtime
20
+ prerelease: false
21
+ version_requirements: !ruby/object:Gem::Requirement
22
+ requirements:
23
+ - - "~>"
24
+ - !ruby/object:Gem::Version
25
+ version: 3.1.8
12
26
  - !ruby/object:Gem::Dependency
13
27
  name: bundler
14
28
  requirement: !ruby/object:Gem::Requirement
@@ -23,6 +37,20 @@ dependencies:
23
37
  - - '='
24
38
  - !ruby/object:Gem::Version
25
39
  version: 2.4.22
40
+ - !ruby/object:Gem::Dependency
41
+ name: csv
42
+ requirement: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - "~>"
45
+ - !ruby/object:Gem::Version
46
+ version: '3.3'
47
+ type: :development
48
+ prerelease: false
49
+ version_requirements: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "~>"
52
+ - !ruby/object:Gem::Version
53
+ version: '3.3'
26
54
  - !ruby/object:Gem::Dependency
27
55
  name: rspec
28
56
  requirement: !ruby/object:Gem::Requirement
@@ -148,7 +176,7 @@ licenses:
148
176
  metadata:
149
177
  bug_tracker_uri: https://github.com/0llirocks/cvss-suite/issues
150
178
  changelog_uri: https://github.com/0llirocks/cvss-suite/blob/master/CHANGES.md
151
- documentation_uri: https://www.rubydoc.info/gems/cvss-suite/4.1.0
179
+ documentation_uri: https://www.rubydoc.info/gems/cvss-suite/4.1.1
152
180
  homepage_uri: https://cvss-suite.0lli.rocks
153
181
  source_code_uri: https://github.com/0llirocks/cvss-suite
154
182
  rdoc_options: []