cvss-suite 3.1.0 → 3.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/rspec.yml +4 -4
  3. data/.github/workflows/rubocop.yml +3 -4
  4. data/.rubocop.yml +20 -0
  5. data/.rubocop_todo.yml +2 -2
  6. data/CHANGES.md +13 -0
  7. data/CODE_OF_CONDUCT.md +9 -2
  8. data/Gemfile +0 -6
  9. data/LICENSE.md +10 -1
  10. data/README.md +20 -5
  11. data/cvss_suite.gemspec +7 -10
  12. data/lib/cvss_suite/cvss.rb +4 -32
  13. data/lib/cvss_suite/cvss2/cvss2.rb +2 -8
  14. data/lib/cvss_suite/cvss2/cvss2_base.rb +0 -6
  15. data/lib/cvss_suite/cvss2/cvss2_environmental.rb +0 -6
  16. data/lib/cvss_suite/cvss2/cvss2_temporal.rb +0 -6
  17. data/lib/cvss_suite/cvss3/cvss3.rb +8 -8
  18. data/lib/cvss_suite/cvss3/cvss3_base.rb +0 -6
  19. data/lib/cvss_suite/cvss3/cvss3_environmental.rb +0 -6
  20. data/lib/cvss_suite/cvss3/cvss3_temporal.rb +0 -6
  21. data/lib/cvss_suite/cvss31/cvss31.rb +8 -8
  22. data/lib/cvss_suite/cvss31/cvss31_base.rb +0 -6
  23. data/lib/cvss_suite/cvss31/cvss31_environmental.rb +0 -6
  24. data/lib/cvss_suite/cvss31/cvss31_temporal.rb +0 -6
  25. data/lib/cvss_suite/cvss40/cvss40.rb +43 -0
  26. data/lib/cvss_suite/cvss40/cvss40_all_up.rb +40 -0
  27. data/lib/cvss_suite/cvss40/cvss40_base.rb +86 -0
  28. data/lib/cvss_suite/cvss40/cvss40_calc_helper.rb +389 -0
  29. data/lib/cvss_suite/cvss40/cvss40_constants_levels.rb +26 -0
  30. data/lib/cvss_suite/cvss40/cvss40_constants_macro_vector_lookup.rb +278 -0
  31. data/lib/cvss_suite/cvss40/cvss40_constants_max_composed.rb +41 -0
  32. data/lib/cvss_suite/cvss40/cvss40_constants_max_severity.rb +31 -0
  33. data/lib/cvss_suite/cvss40/cvss40_environmental.rb +105 -0
  34. data/lib/cvss_suite/cvss40/cvss40_environmental_security.rb +47 -0
  35. data/lib/cvss_suite/cvss40/cvss40_supplemental.rb +66 -0
  36. data/lib/cvss_suite/cvss40/cvss40_threat.rb +34 -0
  37. data/lib/cvss_suite/cvss_31_and_before.rb +50 -0
  38. data/lib/cvss_suite/cvss_40_and_later.rb +45 -0
  39. data/lib/cvss_suite/cvss_metric.rb +4 -6
  40. data/lib/cvss_suite/cvss_property.rb +0 -6
  41. data/lib/cvss_suite/errors.rb +0 -6
  42. data/lib/cvss_suite/extensions/string.rb +8 -0
  43. data/lib/cvss_suite/helpers/cvss31_helper.rb +0 -6
  44. data/lib/cvss_suite/helpers/cvss3_helper.rb +0 -6
  45. data/lib/cvss_suite/invalid_cvss.rb +0 -6
  46. data/lib/cvss_suite/version.rb +1 -7
  47. data/lib/cvss_suite.rb +6 -7
  48. metadata +41 -12
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8d6c9f7e41ba7184e8140cf17c6fc0a1b2dced70a3a0e80a603700c2517f413c
4
- data.tar.gz: 8277aaf7c847feb0d83adcf96f33e85dbbaa4916bb84fb3b1fad5fc1eb99ef57
3
+ metadata.gz: 56b4970c7134073d2940b58730249883898bff82628949a38dfcdb805de8a204
4
+ data.tar.gz: ecee84d8b3d5abec9004c6223fb8ab321b015ee4bbef18a528b24c1776e0d3fa
5
5
  SHA512:
6
- metadata.gz: 3640b87d41a2b7533b756b416e115e8cde0bb4459a8aefe325d0db82816b48dc0b3f32bd2d6c9dde4ab48ec0bec94efc8572e0c94412618070a45ab04012dd04
7
- data.tar.gz: fe15648aa4362009d44ef9159e38f40494b09911582845b29732cb6c6512694c6bdf4d3b57ec412a6e9e76c783c197746dd76a2cce79ce298facad8f4a8ac334
6
+ metadata.gz: d5f8ea8fa286f41fb7505a3f59c5b995f827b57415c486340ac6d3e540baab7e1e81b045f075587e832027d812a46cccaa521abd5ac7dcda6836a9f290ba2139
7
+ data.tar.gz: 948c07fe25adfb5acc09ba85ccfff096f7caaaec3bd832ae5b7da61087ccfb957c58bd1b8a584244a582cdca4252bdf4378fe81c574f1bec2e45c799cca530e4
@@ -8,16 +8,16 @@ jobs:
8
8
  runs-on: ubuntu-latest
9
9
  strategy:
10
10
  matrix:
11
- ruby: [ '2.6', '2.7', '3.0', '3.1' ]
11
+ ruby: [ '2.6', '2.7', '3.0', '3.1', '3.2', '3.3' ]
12
12
  steps:
13
- - uses: actions/checkout@v2
13
+ - uses: actions/checkout@v4
14
14
  - name: Set up ${{ matrix.ruby }}
15
15
  uses: ruby/setup-ruby@v1
16
16
  with:
17
17
  ruby-version: ${{ matrix.ruby }}
18
18
  - name: Install gems
19
19
  run: |
20
- gem install bundler -v ">= 1.10"
21
- bundle install --jobs 4 --retry 3
20
+ gem install bundler -v "2.4.22"
21
+ bundle _2.4.22_ install --jobs 4 --retry 3
22
22
  - name: Run tests
23
23
  run: bundle exec rspec spec
@@ -8,15 +8,14 @@ jobs:
8
8
  runs-on: ubuntu-latest
9
9
 
10
10
  steps:
11
- - uses: actions/checkout@v2
11
+ - uses: actions/checkout@v4
12
12
  - name: Set up Ruby 2.6
13
13
  uses: ruby/setup-ruby@v1
14
14
  with:
15
15
  ruby-version: 2.6
16
16
  - name: Install gems
17
17
  run: |
18
- gem update --system
19
- gem install bundler -v ">= 1.10"
20
- gem install rubocop
18
+ gem install bundler -v "2.4.22"
19
+ bundle install --jobs 4 --retry 3
21
20
  - name: Run checks
22
21
  run: rubocop -F --fail-level C -f s
data/.rubocop.yml CHANGED
@@ -4,6 +4,10 @@ AllCops:
4
4
  TargetRubyVersion: 2.6
5
5
  SuggestExtensions: false
6
6
 
7
+ Metrics/AbcSize:
8
+ Exclude:
9
+ - 'lib/cvss_suite/cvss40/cvss40_calc_helper.rb'
10
+
7
11
  Metrics/LineLength:
8
12
  Max: 120
9
13
  Exclude:
@@ -14,17 +18,33 @@ Metrics/ClassLength:
14
18
  Exclude:
15
19
  - 'lib/cvss_suite/cvss3/cvss3_environmental.rb'
16
20
  - 'lib/cvss_suite/cvss31/cvss31_environmental.rb'
21
+ - 'lib/cvss_suite/cvss40/cvss40_calc_helper.rb'
22
+
23
+ Metrics/CyclomaticComplexity:
24
+ Exclude:
25
+ - 'lib/cvss_suite/cvss40/cvss40_calc_helper.rb'
17
26
 
18
27
  Metrics/MethodLength:
19
28
  Exclude:
20
29
  - 'lib/cvss_suite/cvss3/cvss3_environmental.rb'
21
30
  - 'lib/cvss_suite/cvss31/cvss31_environmental.rb'
31
+ - 'lib/cvss_suite/cvss40/cvss40_environmental.rb'
32
+ - 'lib/cvss_suite/cvss40/cvss40_calc_helper.rb'
33
+
34
+ Metrics/ModuleLength:
35
+ Exclude:
36
+ - 'lib/cvss_suite/cvss40/cvss40_constants_macro_vector_lookup.rb'
37
+
38
+ Metrics/PerceivedComplexity:
39
+ Exclude:
40
+ - 'lib/cvss_suite/cvss40/cvss40_calc_helper.rb'
22
41
 
23
42
  Metrics/BlockLength:
24
43
  Exclude:
25
44
  - 'spec/cvss2/cvss2_spec.rb'
26
45
  - 'spec/cvss3/cvss3_spec.rb'
27
46
  - 'spec/cvss31/cvss31_spec.rb'
47
+ - 'spec/cvss40/cvss40_spec.rb'
28
48
 
29
49
  Style/IfUnlessModifier:
30
50
  Exclude:
data/.rubocop_todo.yml CHANGED
@@ -36,7 +36,7 @@ Metrics/ClassLength:
36
36
  # Offense count: 1
37
37
  # Configuration parameters: IgnoredMethods.
38
38
  Metrics/CyclomaticComplexity:
39
- Max: 9
39
+ Max: 13
40
40
 
41
41
  # Offense count: 13
42
42
  # Configuration parameters: CountComments, ExcludedMethods.
@@ -51,7 +51,7 @@ Metrics/ParameterLists:
51
51
  # Offense count: 1
52
52
  # Configuration parameters: IgnoredMethods.
53
53
  Metrics/PerceivedComplexity:
54
- Max: 10
54
+ Max: 14
55
55
 
56
56
  # Offense count: 1
57
57
  Naming/AccessorMethodName:
data/CHANGES.md CHANGED
@@ -2,6 +2,19 @@
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.0] - 2024-05-04
6
+
7
+ ### Improvements
8
+ * Add support for CVSS version 4. Closes [#32](https://github.com/0llirocks/cvss-suite/issues/32). Many thanks to @brphelps for adding this feature.
9
+
10
+ ### Notes
11
+ * CVSS version 4 no longer has multiple scores, only one overall score. Keep that in mind when using CVSS version 4.
12
+
13
+ ## [3.1.1] - 2023-10-15
14
+
15
+ ### Fixes
16
+ * CVSS prefix is missing in v3.1.0. Fixes [#33](https://github.com/0llirocks/cvss-suite/issues/33)
17
+
5
18
  ## [3.1.0] - 2022-09-27
6
19
 
7
20
  ### Fixes
data/CODE_OF_CONDUCT.md CHANGED
@@ -1,9 +1,16 @@
1
1
  CVSS-Suite, a Ruby gem to manage the CVSS vector
2
2
 
3
3
  Copyright (c) 2016-2022 Siemens AG
4
- Copyright (c) 2022 0llirocks
4
+ Copyright (c) 2022-2024 0llirocks
5
5
 
6
- Authors: 0llirocks <http://0lli.rocks>
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>
7
14
 
8
15
  This work is licensed under the terms of the MIT license.
9
16
  See the LICENSE.md file in the top-level directory.
data/Gemfile CHANGED
@@ -1,11 +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 0llirocks
5
- #
6
- # Authors:
7
- # 0llirocks <http://0lli.rocks>
8
- #
9
3
  # This work is licensed under the terms of the MIT license.
10
4
  # See the LICENSE.md file in the top-level directory.
11
5
 
data/LICENSE.md CHANGED
@@ -1,7 +1,16 @@
1
1
  The MIT License (MIT)
2
2
 
3
3
  Copyright (c) 2016-2022 Siemens AG
4
- Copyright (c) 2022 0llirocks
4
+ Copyright (c) 2022-2024 0llirocks
5
+
6
+ Authors:
7
+ 0llirocks <https://github.com/0llirocks>
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>
5
14
 
6
15
  Permission is hereby granted, free of charge, to any person obtaining a copy of
7
16
  this software and associated documentation files (the "Software"), to deal in
data/README.md CHANGED
@@ -5,6 +5,7 @@
5
5
  [![Cvss Support](https://img.shields.io/badge/CVSS-v2-brightgreen.svg)](https://www.first.org/cvss/v2/guide)
6
6
  [![Cvss Support](https://img.shields.io/badge/CVSS-v3.0-brightgreen.svg)](https://www.first.org/cvss/v3.0/user-guide)
7
7
  [![Cvss Support](https://img.shields.io/badge/CVSS-v3.1-brightgreen.svg)](https://www.first.org/cvss/v3.1/user-guide)
8
+ [![Cvss Support](https://img.shields.io/badge/CVSS-v4.0-brightgreen.svg)](https://www.first.org/cvss/v4.0/user-guide)
8
9
  [![RSpec](https://github.com/0llirocks/cvss-suite/workflows/RSpec/badge.svg)](https://github.com/0llirocks/cvss-suite/actions)
9
10
 
10
11
  This Ruby gem helps you to process the vector of the [**Common Vulnerability Scoring System**](https://www.first.org/cvss/specification-document).
@@ -18,6 +19,12 @@ Add this line to your application's Gemfile:
18
19
  gem 'cvss-suite'
19
20
  ```
20
21
 
22
+ Since the naming of this gem is not following the naming convention you can also add the following line to automatically require the gem:
23
+
24
+ ```ruby
25
+ gem 'cvss-suite', require: 'cvss_suite'
26
+ ```
27
+
21
28
  And then execute:
22
29
 
23
30
  $ bundle
@@ -39,12 +46,12 @@ If you are still using CvssSuite 1.x please refer to the [specific branch](https
39
46
  ```ruby
40
47
  require 'cvss_suite'
41
48
 
42
- cvss3 = CvssSuite.new('CVSS:3.0/AV:L/AC:H/PR:L/UI:R/S:C/C:L/I:L/A:L/CR:L/IR:M/AR:H/MAV:N/MAC:H/MPR:N/MUI:R/MS:U/MC:N/MI:L/MA:H')
49
+ cvss4 = CvssSuite.new('CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N')
43
50
 
44
- vector = cvss3.vector # 'CVSS:3.0/AV:L/AC:H/PR:L/UI:R/S:C/C:L/I:L/A:L/CR:L/IR:M/AR:H/MAV:N/MAC:H/MPR:N/MUI:R/MS:U/MC:N/MI:L/MA:H'
45
- version = cvss3.version # 3.0
46
- valid = cvss3.valid? # true
47
- severity = cvss3.severity # 'High'
51
+ vector = cvss4.vector # 'CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N'
52
+ version = cvss4.version # 4.0
53
+ valid = cvss4.valid? # true
54
+ severity = cvss4.severity # 'Critical'
48
55
 
49
56
  cvss31 = CvssSuite.new('CVSS:3.1/AV:P/AC:H/PR:L/UI:R/S:U/C:L/I:L/A:H/E:H/RL:U/RC:U')
50
57
 
@@ -53,6 +60,13 @@ version = cvss31.version # 3.1
53
60
  valid = cvss31.valid? # true
54
61
  severity = cvss31.severity # 'Medium'
55
62
 
63
+ cvss3 = CvssSuite.new('CVSS:3.0/AV:L/AC:H/PR:L/UI:R/S:C/C:L/I:L/A:L/CR:L/IR:M/AR:H/MAV:N/MAC:H/MPR:N/MUI:R/MS:U/MC:N/MI:L/MA:H')
64
+
65
+ vector = cvss3.vector # 'CVSS:3.0/AV:L/AC:H/PR:L/UI:R/S:C/C:L/I:L/A:L/CR:L/IR:M/AR:H/MAV:N/MAC:H/MPR:N/MUI:R/MS:U/MC:N/MI:L/MA:H'
66
+ version = cvss3.version # 3.0
67
+ valid = cvss3.valid? # true
68
+ severity = cvss3.severity # 'High'
69
+
56
70
  cvss = CvssSuite.new('AV:A/AC:M/Au:S/C:P/I:P/A:P/E:POC/RL:TF/RC:UC/CDP:L/TD:M/CR:M/IR:M/AR:M')
57
71
 
58
72
  vector = cvss.vector # 'AV:A/AC:M/Au:S/C:P/I:P/A:P/E:POC/RL:TF/RC:UC/CDP:L/TD:M/CR:M/IR:M/AR:M'
@@ -61,6 +75,7 @@ valid = cvss.valid? # true
61
75
  severity = cvss.severity # 'Low'
62
76
 
63
77
  # Scores
78
+ score = cvss4.overall_score # 9.3, cvss4 only has overall score
64
79
  base_score = cvss.base_score # 4.9
65
80
  temporal_score = cvss.temporal_score # 3.6
66
81
  environmental_score = cvss.environmental_score # 3.2
data/cvss_suite.gemspec CHANGED
@@ -1,11 +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 0llirocks
5
- #
6
- # Authors:
7
- # 0llirocks <http://0lli.rocks>
8
- #
9
3
  # This work is licensed under the terms of the MIT license.
10
4
  # See the LICENSE.md file in the top-level directory.
11
5
 
@@ -22,14 +16,16 @@ Gem::Specification.new do |spec|
22
16
  spec.authors = ['0llirocks']
23
17
 
24
18
  spec.summary = 'Ruby gem for processing cvss vectors.'
25
- spec.description = 'This Ruby gem helps you to process the vector of the Common Vulnerability Scoring System (https://www.first.org/cvss/specification-document).
26
- Besides calculating the Base, Temporal and Environmental Score, you are able to extract the selected option.'
19
+ spec.description = 'This Ruby gem calculates the score based on the vector of the
20
+ Common Vulnerability Scoring System (https://www.first.org/cvss/specification-document)
21
+ in version 4.0, 3.1, 3.0 and 2.'
22
+
23
+ spec.homepage = 'https://cvss-suite.0lli.rocks'
27
24
 
28
25
  spec.metadata = {
29
26
  'bug_tracker_uri' => 'https://github.com/0llirocks/cvss-suite/issues',
30
27
  'changelog_uri' => 'https://github.com/0llirocks/cvss-suite/blob/master/CHANGES.md',
31
28
  'documentation_uri' => "https://www.rubydoc.info/gems/cvss-suite/#{CvssSuite::VERSION}",
32
- 'homepage_uri' => 'https://cvss-suite.0lli.rocks',
33
29
  'source_code_uri' => 'https://github.com/0llirocks/cvss-suite'
34
30
  }
35
31
 
@@ -40,8 +36,9 @@ Besides calculating the Base, Temporal and Environmental Score, you are able to
40
36
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
41
37
  spec.require_paths = ['lib']
42
38
 
43
- spec.add_development_dependency 'bundler', '>= 1.10'
39
+ spec.add_development_dependency 'bundler', '2.4.22'
44
40
  spec.add_development_dependency 'rspec', '~> 3.4'
45
41
  spec.add_development_dependency 'rspec-its', '~> 1.2'
42
+ spec.add_development_dependency 'rubocop', '1.50.2'
46
43
  spec.add_development_dependency 'simplecov', '~> 0.18'
47
44
  end
@@ -1,11 +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 0llirocks
5
- #
6
- # Authors:
7
- # 0llirocks <http://0lli.rocks>
8
- #
9
3
  # This work is licensed under the terms of the MIT license.
10
4
  # See the LICENSE.md file in the top-level directory.
11
5
 
@@ -15,11 +9,7 @@ module CvssSuite
15
9
  class Cvss
16
10
  ##
17
11
  # Metric of a CVSS vector.
18
- attr_reader :base, :temporal, :environmental
19
-
20
- ##
21
- # Returns the vector itself.
22
- attr_reader :vector
12
+ attr_reader :base
23
13
 
24
14
  ##
25
15
  # Creates a new CVSS vector by a +vector+.
@@ -34,20 +24,6 @@ module CvssSuite
34
24
  init_metrics
35
25
  end
36
26
 
37
- ##
38
- # Returns if CVSS vector is valid.
39
- def valid?
40
- if @amount_of_properties >= required_amount_of_properties
41
- base = @base.valid?
42
- temporal = @base.valid? && @temporal.valid?
43
- environmental = @base.valid? && @environmental.valid?
44
- full = @base.valid? && @temporal.valid? && @environmental.valid?
45
- base || temporal || environmental || full
46
- else
47
- false
48
- end
49
- end
50
-
51
27
  ##
52
28
  # Returns the severity of the CVSS vector.
53
29
  def severity
@@ -71,13 +47,9 @@ module CvssSuite
71
47
  end
72
48
 
73
49
  ##
74
- # Returns the Overall Score of the CVSS vector.
75
- def overall_score
76
- check_validity
77
- return temporal_score if @temporal.valid? && !@environmental.valid?
78
- return environmental_score if @environmental.valid?
79
-
80
- base_score
50
+ # Returns the vector itself.
51
+ def vector
52
+ @vector.to_s
81
53
  end
82
54
 
83
55
  private
@@ -1,15 +1,9 @@
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 0llirocks
5
- #
6
- # Authors:
7
- # 0llirocks <http://0lli.rocks>
8
- #
9
3
  # This work is licensed under the terms of the MIT license.
10
4
  # See the LICENSE.md file in the top-level directory.
11
5
 
12
- require_relative '../cvss'
6
+ require_relative '../cvss_31_and_before'
13
7
  require_relative 'cvss2_base'
14
8
  require_relative 'cvss2_temporal'
15
9
  require_relative 'cvss2_environmental'
@@ -17,7 +11,7 @@ require_relative 'cvss2_environmental'
17
11
  module CvssSuite
18
12
  ##
19
13
  # This class represents a CVSS vector in version 2.
20
- class Cvss2 < Cvss
14
+ class Cvss2 < Cvss31AndBefore
21
15
  ##
22
16
  # Returns the Version of the CVSS vector.
23
17
  def version
@@ -1,11 +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 0llirocks
5
- #
6
- # Authors:
7
- # 0llirocks <http://0lli.rocks>
8
- #
9
3
  # This work is licensed under the terms of the MIT license.
10
4
  # See the LICENSE.md file in the top-level directory.
11
5
 
@@ -1,11 +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 0llirocks
5
- #
6
- # Authors:
7
- # 0llirocks <http://0lli.rocks>
8
- #
9
3
  # This work is licensed under the terms of the MIT license.
10
4
  # See the LICENSE.md file in the top-level directory.
11
5
 
@@ -1,11 +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 0llirocks
5
- #
6
- # Authors:
7
- # 0llirocks <http://0lli.rocks>
8
- #
9
3
  # This work is licensed under the terms of the MIT license.
10
4
  # See the LICENSE.md file in the top-level directory.
11
5
 
@@ -1,15 +1,9 @@
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 0llirocks
5
- #
6
- # Authors:
7
- # 0llirocks <http://0lli.rocks>
8
- #
9
3
  # This work is licensed under the terms of the MIT license.
10
4
  # See the LICENSE.md file in the top-level directory.
11
5
 
12
- require_relative '../cvss'
6
+ require_relative '../cvss_31_and_before'
13
7
  require_relative 'cvss3_base'
14
8
  require_relative 'cvss3_temporal'
15
9
  require_relative 'cvss3_environmental'
@@ -17,7 +11,7 @@ require_relative 'cvss3_environmental'
17
11
  module CvssSuite
18
12
  ##
19
13
  # This class represents a CVSS vector in version 3.0.
20
- class Cvss3 < Cvss
14
+ class Cvss3 < Cvss31AndBefore
21
15
  ##
22
16
  # Returns the Version of the CVSS vector.
23
17
  def version
@@ -45,6 +39,12 @@ module CvssSuite
45
39
  Cvss3Helper.round_up(@environmental.score(@base, @temporal))
46
40
  end
47
41
 
42
+ ##
43
+ # Returns the vector itself.
44
+ def vector
45
+ "#{CvssSuite::CVSS_VECTOR_BEGINNINGS.find { |beginning| beginning[:version] == version }[:string]}#{@vector}"
46
+ end
47
+
48
48
  private
49
49
 
50
50
  def init_metrics
@@ -1,11 +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 0llirocks
5
- #
6
- # Authors:
7
- # 0llirocks <http://0lli.rocks>
8
- #
9
3
  # This work is licensed under the terms of the MIT license.
10
4
  # See the LICENSE.md file in the top-level directory.
11
5
 
@@ -1,11 +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 0llirocks
5
- #
6
- # Authors:
7
- # 0llirocks <http://0lli.rocks>
8
- #
9
3
  # This work is licensed under the terms of the MIT license.
10
4
  # See the LICENSE.md file in the top-level directory.
11
5
 
@@ -1,11 +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 0llirocks
5
- #
6
- # Authors:
7
- # 0llirocks <http://0lli.rocks>
8
- #
9
3
  # This work is licensed under the terms of the MIT license.
10
4
  # See the LICENSE.md file in the top-level directory.
11
5
 
@@ -1,15 +1,9 @@
1
1
  # CVSS-Suite, a Ruby gem to manage the CVSS vector
2
2
  #
3
- # Copyright (c) 2019-2022 Siemens AG
4
- # Copyright (c) 2022 0llirocks
5
- #
6
- # Authors:
7
- # 0llirocks <http://0lli.rocks>
8
- #
9
3
  # This work is licensed under the terms of the MIT license.
10
4
  # See the LICENSE.md file in the top-level directory.
11
5
 
12
- require_relative '../cvss'
6
+ require_relative '../cvss_31_and_before'
13
7
  require_relative 'cvss31_base'
14
8
  require_relative 'cvss31_temporal'
15
9
  require_relative 'cvss31_environmental'
@@ -18,7 +12,7 @@ require_relative '../helpers/cvss31_helper'
18
12
  module CvssSuite
19
13
  ##
20
14
  # This class represents a CVSS vector in version 3.1.
21
- class Cvss31 < Cvss
15
+ class Cvss31 < Cvss31AndBefore
22
16
  ##
23
17
  # Returns the Version of the CVSS vector.
24
18
 
@@ -50,6 +44,12 @@ module CvssSuite
50
44
  Cvss31Helper.round_up(@environmental.score(@base, @temporal))
51
45
  end
52
46
 
47
+ ##
48
+ # Returns the vector itself.
49
+ def vector
50
+ "#{CvssSuite::CVSS_VECTOR_BEGINNINGS.find { |beginning| beginning[:version] == version }[:string]}#{@vector}"
51
+ end
52
+
53
53
  private
54
54
 
55
55
  def init_metrics
@@ -1,11 +1,5 @@
1
1
  # CVSS-Suite, a Ruby gem to manage the CVSS vector
2
2
  #
3
- # Copyright (c) 2019-2022 Siemens AG
4
- # Copyright (c) 2022 0llirocks
5
- #
6
- # Authors:
7
- # 0llirocks <http://0lli.rocks>
8
- #
9
3
  # This work is licensed under the terms of the MIT license.
10
4
  # See the LICENSE.md file in the top-level directory.
11
5
 
@@ -1,11 +1,5 @@
1
1
  # CVSS-Suite, a Ruby gem to manage the CVSS vector
2
2
  #
3
- # Copyright (c) 2019-2022 Siemens AG
4
- # Copyright (c) 2022 0llirocks
5
- #
6
- # Authors:
7
- # 0llirocks <http://0lli.rocks>
8
- #
9
3
  # This work is licensed under the terms of the MIT license.
10
4
  # See the LICENSE.md file in the top-level directory.
11
5
 
@@ -1,11 +1,5 @@
1
1
  # CVSS-Suite, a Ruby gem to manage the CVSS vector
2
2
  #
3
- # Copyright (c) 2019-2022 Siemens AG
4
- # Copyright (c) 2022 0llirocks
5
- #
6
- # Authors:
7
- # 0llirocks <http://0lli.rocks>
8
- #
9
3
  # This work is licensed under the terms of the MIT license.
10
4
  # See the LICENSE.md file in the top-level directory.
11
5
 
@@ -0,0 +1,43 @@
1
+ # CVSS-Suite, a Ruby gem to manage the CVSS vector
2
+ #
3
+ # This work is licensed under the terms of the MIT license.
4
+ # See the LICENSE.md file in the top-level directory.
5
+
6
+ require_relative '../cvss_40_and_later'
7
+ require_relative 'cvss40_base'
8
+ require_relative 'cvss40_supplemental'
9
+ require_relative 'cvss40_threat'
10
+ require_relative 'cvss40_environmental'
11
+ require_relative 'cvss40_environmental_security'
12
+ require_relative 'cvss40_all_up'
13
+
14
+ module CvssSuite
15
+ ##
16
+ # This class represents a CVSS vector in version 4.0.
17
+ class Cvss40 < Cvss40AndLater
18
+ ##
19
+ # Returns the Version of the CVSS vector.
20
+
21
+ def version
22
+ 4.0
23
+ end
24
+
25
+ ##
26
+ # Returns the vector itself.
27
+ def vector
28
+ "#{CvssSuite::CVSS_VECTOR_BEGINNINGS.find { |beginning| beginning[:version] == version }[:string]}#{@vector}"
29
+ end
30
+
31
+ private
32
+
33
+ def init_metrics
34
+ @base = Cvss40Base.new(@properties)
35
+ @threat = Cvss40Threat.new(@properties)
36
+ @environmental = Cvss40Environmental.new(@properties)
37
+ @environmental_security = Cvss40EnvironmentalSecurity.new(@properties)
38
+ @supplemental = Cvss40Supplemental.new(@properties)
39
+
40
+ @all_up = Cvss40AllUp.new(@properties, @base, @threat, @environmental, @environmental_security, @supplemental)
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,40 @@
1
+ # CVSS-Suite, a Ruby gem to manage the CVSS vector
2
+ #
3
+ # This work is licensed under the terms of the MIT license.
4
+ # See the LICENSE.md file in the top-level directory.
5
+
6
+ require_relative '../cvss_property'
7
+ require_relative '../cvss_metric'
8
+ require_relative 'cvss40_base'
9
+ require_relative 'cvss40_threat'
10
+
11
+ module CvssSuite
12
+ ##
13
+ # This class represents a CVSS Threat metric in version 3.1.
14
+ class Cvss40AllUp < CvssMetric
15
+ ##
16
+ # Returns score of this metric
17
+ def score
18
+ Cvss40CalcHelper.new(@properties.map { |p| [p.abbreviation, p.selected_value[:abbreviation]] }.to_h).score
19
+ end
20
+
21
+ def initialize(properties, base, threat, environmental, environmental_security, supplemental)
22
+ @properties_to_later_initialize_from = properties
23
+ @base = base
24
+ @threat = threat
25
+ @environmental = environmental
26
+ @environmental_security = environmental_security
27
+ @supplemental = supplemental
28
+ super(properties)
29
+ end
30
+
31
+ private
32
+
33
+ def init_properties
34
+ # All up takes it's properties from all other scores
35
+ properties_to_add = @base.properties + @threat.properties + @environmental.properties +
36
+ @environmental_security.properties + @supplemental.properties
37
+ properties_to_add.each { |p| @properties.push p }
38
+ end
39
+ end
40
+ end