cvss-suite 1.1.1 → 1.2.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. checksums.yaml +5 -5
  2. data/.github/ISSUE_TEMPLATE/bug_report.md +21 -0
  3. data/.github/ISSUE_TEMPLATE/custom.md +7 -0
  4. data/.github/ISSUE_TEMPLATE/feature_request.md +17 -0
  5. data/.github/workflows/rspec.yml +23 -0
  6. data/.gitignore +1 -0
  7. data/.rubocop.yml +39 -1
  8. data/.rubocop_todo.yml +124 -0
  9. data/CHANGES.md +62 -0
  10. data/PULL_REQUEST_TEMPLATE.md +24 -0
  11. data/README.md +37 -9
  12. data/_config.yml +1 -0
  13. data/bin/console +3 -3
  14. data/cvss_suite.gemspec +16 -13
  15. data/lib/cvss_suite.rb +13 -6
  16. data/lib/cvss_suite/cvss.rb +94 -64
  17. data/lib/cvss_suite/cvss2/cvss2.rb +52 -26
  18. data/lib/cvss_suite/cvss2/cvss2_base.rb +70 -73
  19. data/lib/cvss_suite/cvss2/cvss2_environmental.rb +49 -50
  20. data/lib/cvss_suite/cvss2/cvss2_temporal.rb +41 -39
  21. data/lib/cvss_suite/cvss3/cvss3.rb +34 -26
  22. data/lib/cvss_suite/cvss3/cvss3_base.rb +64 -65
  23. data/lib/cvss_suite/cvss3/cvss3_environmental.rb +159 -107
  24. data/lib/cvss_suite/cvss3/cvss3_temporal.rb +42 -40
  25. data/lib/cvss_suite/cvss31/cvss31.rb +61 -0
  26. data/lib/cvss_suite/cvss31/cvss31_base.rb +94 -0
  27. data/lib/cvss_suite/cvss31/cvss31_environmental.rb +196 -0
  28. data/lib/cvss_suite/cvss31/cvss31_temporal.rb +59 -0
  29. data/lib/cvss_suite/cvss_metric.rb +31 -31
  30. data/lib/cvss_suite/cvss_property.rb +56 -54
  31. data/lib/cvss_suite/helpers/cvss31_helper.rb +27 -0
  32. data/lib/cvss_suite/helpers/cvss3_helper.rb +20 -13
  33. data/lib/cvss_suite/invalid_cvss.rb +31 -32
  34. data/lib/cvss_suite/version.rb +2 -2
  35. metadata +22 -26
  36. data/.travis.yml +0 -4
  37. data/lib/cvss_suite/helpers/extensions.rb +0 -32
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 67b9524624c103f1410747cc5601fc6c51bdaeb3
4
- data.tar.gz: 92eb12a5d7266cdfcef91ee3d6090d59d493b8c8
2
+ SHA256:
3
+ metadata.gz: '09094d21733286857b9b006672aa297d88858737f58656b2b48627d23bce3e69'
4
+ data.tar.gz: 524220ad72a9e052adc3742d3b32d1df3d66f0f5bf0a0c8cfd83265bf5e58d09
5
5
  SHA512:
6
- metadata.gz: c575ffb21ee0c1742911641921e3d661bbe421e77cb073080281b98bc2133fe8aaab4ac5ab521455a9253794a91a58d71ebdeddaa7ce70127e718856f0cfa0b3
7
- data.tar.gz: af23d1944795b0eb5eb4172ad742199f9f8aefc22cf17563c61e22ac6883848aa38d7564896ed84d2360e4becec28ca9abe84c71cb714ac933e511e2e302c392
6
+ metadata.gz: 9d871c1e5397598c1261c293524abee855f5c925e62c1e57aeb07473c7ec00c4c98c7ec146623b3a1e9737d0a0016a33098ac539c872762c88502f123501c69e
7
+ data.tar.gz: 3fed8bb40cab71f344a6bd339b50c75120942595ffbed2e4b4f0d534ef778ac0619681e648c95a74fac59615a748dd8a94931f0934744948a20ce7306b050e17
@@ -0,0 +1,21 @@
1
+ ---
2
+ name: Bug report
3
+ about: Create a report to help us improve
4
+
5
+ ---
6
+
7
+ ### Subject of the issue
8
+ Describe your issue here.
9
+
10
+ ### Your environment
11
+ * version of cvss-suite gem
12
+ * version of ruby
13
+
14
+ ### Steps to reproduce
15
+ Tell us how to reproduce this issue. Please provide a working demo.
16
+
17
+ ### Expected behaviour
18
+ Tell us what should happen.
19
+
20
+ ### Actual behaviour
21
+ Tell us what happens instead.
@@ -0,0 +1,7 @@
1
+ ---
2
+ name: Custom issue template
3
+ about: Describe this issue template's purpose here.
4
+
5
+ ---
6
+
7
+
@@ -0,0 +1,17 @@
1
+ ---
2
+ name: Feature request
3
+ about: Suggest an idea for this project
4
+
5
+ ---
6
+
7
+ **Is your feature request related to a problem? Please describe.**
8
+ A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
9
+
10
+ **Describe the solution you'd like**
11
+ A clear and concise description of what you want to happen.
12
+
13
+ **Describe alternatives you've considered**
14
+ A clear and concise description of any alternative solutions or features you've considered.
15
+
16
+ **Additional context**
17
+ Add any other context or screenshots about the feature request here.
@@ -0,0 +1,23 @@
1
+ name: RSpec
2
+
3
+ on: [push,pull_request]
4
+
5
+ jobs:
6
+ build:
7
+
8
+ runs-on: ubuntu-latest
9
+ strategy:
10
+ matrix:
11
+ ruby: [ '2.4', '2.5', '2.6', '2.7' ]
12
+ steps:
13
+ - uses: actions/checkout@v2
14
+ - name: Set up ${{ matrix.ruby }}
15
+ uses: actions/setup-ruby@v1
16
+ with:
17
+ ruby-version: ${{ matrix.ruby }}
18
+ - name: Build
19
+ run: |
20
+ gem install bundler -v ">= 1.10"
21
+ bundle install --jobs 4 --retry 3
22
+ - name: Run tests
23
+ run: bundle exec rspec spec
data/.gitignore CHANGED
@@ -10,3 +10,4 @@
10
10
  /tmp/
11
11
  .idea/
12
12
  /*.gem
13
+ .ruby-version
@@ -1,2 +1,40 @@
1
+ inherit_from: .rubocop_todo.yml
2
+
1
3
  Metrics/LineLength:
2
- Max: 120
4
+ Max: 120
5
+ Exclude:
6
+ - 'lib/cvss_suite/cvss3/cvss3_environmental.rb'
7
+ - 'lib/cvss_suite/cvss31/cvss31_environmental.rb'
8
+
9
+ Metrics/ClassLength:
10
+ Exclude:
11
+ - 'lib/cvss_suite/cvss3/cvss3_environmental.rb'
12
+ - 'lib/cvss_suite/cvss31/cvss31_environmental.rb'
13
+
14
+ Metrics/MethodLength:
15
+ Exclude:
16
+ - 'lib/cvss_suite/cvss3/cvss3_environmental.rb'
17
+ - 'lib/cvss_suite/cvss31/cvss31_environmental.rb'
18
+
19
+ Metrics/BlockLength:
20
+ Exclude:
21
+ - 'spec/cvss3/cvss3_spec.rb'
22
+ - 'spec/cvss31/cvss31_spec.rb'
23
+
24
+ Style/IfUnlessModifier:
25
+ Exclude:
26
+ - 'lib/cvss_suite/cvss3/cvss3_environmental.rb'
27
+ - 'lib/cvss_suite/cvss31/cvss31_environmental.rb'
28
+
29
+ Style/GuardClause:
30
+ Exclude:
31
+ - 'lib/cvss_suite/cvss3/cvss3_environmental.rb'
32
+ - 'lib/cvss_suite/cvss31/cvss31_environmental.rb'
33
+
34
+ Style/ConditionalAssignment:
35
+ Exclude:
36
+ - 'lib/cvss_suite/cvss3/cvss3_environmental.rb'
37
+ - 'lib/cvss_suite/cvss31/cvss31_environmental.rb'
38
+
39
+ Style/FrozenStringLiteralComment:
40
+ Enabled: false
@@ -0,0 +1,124 @@
1
+ # `rubocop --auto-gen-config`
2
+ # on 2020-05-05 17:47:10 +0200 using RuboCop version 0.82.0.
3
+ # The point is for the user to remove these configuration records
4
+ # one by one as the offenses are removed from the code base.
5
+ # Note that changes in the inspected code, or installation of new
6
+ # versions of RuboCop, may require this file to be generated again.
7
+
8
+ # Offense count: 1
9
+ Lint/IneffectiveAccessModifier:
10
+ Exclude:
11
+ - 'lib/cvss_suite.rb'
12
+
13
+ # Offense count: 1
14
+ # Configuration parameters: ContextCreatingMethods, MethodCreatingMethods.
15
+ Lint/UselessAccessModifier:
16
+ Exclude:
17
+ - 'lib/cvss_suite.rb'
18
+
19
+ # Offense count: 3
20
+ Lint/UselessAssignment:
21
+ Exclude:
22
+ - 'lib/cvss_suite/cvss.rb'
23
+ - 'lib/cvss_suite/cvss3/cvss3_environmental.rb'
24
+ - 'lib/cvss_suite/cvss31/cvss31_environmental.rb'
25
+
26
+ # Offense count: 8
27
+ # Configuration parameters: IgnoredMethods.
28
+ Metrics/AbcSize:
29
+ Max: 35
30
+
31
+ # Offense count: 5
32
+ # Configuration parameters: CountComments, ExcludedMethods.
33
+ # ExcludedMethods: refine
34
+ Metrics/BlockLength:
35
+ Max: 50
36
+
37
+ # Offense count: 2
38
+ # Configuration parameters: CountComments.
39
+ Metrics/ClassLength:
40
+ Max: 102
41
+
42
+ # Offense count: 2
43
+ # Configuration parameters: CountComments.
44
+ Metrics/ClassLength:
45
+ Max: 101
46
+
47
+ # Offense count: 1
48
+ # Configuration parameters: IgnoredMethods.
49
+ Metrics/CyclomaticComplexity:
50
+ Max: 9
51
+
52
+ # Offense count: 13
53
+ # Configuration parameters: CountComments, ExcludedMethods.
54
+ Metrics/MethodLength:
55
+ Max: 63
56
+
57
+ # Offense count: 1
58
+ # Configuration parameters: CountKeywordArgs.
59
+ Metrics/ParameterLists:
60
+ Max: 6
61
+
62
+ # Offense count: 1
63
+ # Configuration parameters: IgnoredMethods.
64
+ Metrics/PerceivedComplexity:
65
+ Max: 10
66
+
67
+ # Offense count: 1
68
+ Naming/AccessorMethodName:
69
+ Exclude:
70
+ - 'lib/cvss_suite/cvss_property.rb'
71
+
72
+ # Offense count: 31
73
+ # Configuration parameters: AllowedChars.
74
+ Style/AsciiComments:
75
+ Enabled: false
76
+
77
+ # Offense count: 20
78
+ Style/Documentation:
79
+ Enabled: false
80
+
81
+ # Offense count: 2
82
+ # Configuration parameters: MinBodyLength.
83
+ Style/GuardClause:
84
+ Exclude:
85
+ - 'lib/cvss_suite/helpers/extensions.rb'
86
+
87
+ # Offense count: 1
88
+ # Cop supports --auto-correct.
89
+ Style/IfUnlessModifier:
90
+ Exclude:
91
+ - 'lib/cvss_suite.rb'
92
+
93
+ # Offense count: 2
94
+ # Cop supports --auto-correct.
95
+ # Configuration parameters: EnforcedStyle.
96
+ # SupportedStyles: literals, strict
97
+ Style/MutableConstant:
98
+ Exclude:
99
+ - 'lib/cvss_suite.rb'
100
+ - 'lib/cvss_suite/version.rb'
101
+
102
+ # Offense count: 8
103
+ # Cop supports --auto-correct.
104
+ # Configuration parameters: Strict.
105
+ Style/NumericLiterals:
106
+ MinDigits: 7
107
+
108
+ # Offense count: 3
109
+ # Cop supports --auto-correct.
110
+ # Configuration parameters: AutoCorrect, EnforcedStyle, IgnoredMethods.
111
+ # SupportedStyles: predicate, comparison
112
+ Style/NumericPredicate:
113
+ Exclude:
114
+ - 'spec/**/*'
115
+ - 'lib/cvss_suite/cvss2/cvss2_base.rb'
116
+ - 'lib/cvss_suite/helpers/extensions.rb'
117
+
118
+ # Offense count: 1
119
+ # Cop supports --auto-correct.
120
+ # Configuration parameters: ConvertCodeThatCanStartToReturnNil, AllowedMethods.
121
+ # AllowedMethods: present?, blank?, presence, try, try!
122
+ Style/SafeNavigation:
123
+ Exclude:
124
+ - 'lib/cvss_suite/cvss_metric.rb'
data/CHANGES.md CHANGED
@@ -2,6 +2,68 @@
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
+ ## [1.2.3] - 2020-12-05
6
+
7
+ ### Fixes
8
+ * CVSS v2 now returns the correct severity values based on NVD recommendation
9
+ * CVSS v2 now supports vectors which are enclosed in parenthesis e.g. (AV:N/AC:L/Au:N/C:P/I:P/A:P)
10
+
11
+ ## [1.2.2] - 2020-07-19
12
+
13
+ ### Fixes
14
+ Fixed an error that resulted in incorrect environmental score if modified attributes were not defined.
15
+
16
+ ## [1.2.1] - 2020-05-10
17
+
18
+ ### Improvements
19
+ * Added CvssSuite module to every class (thanks to @fwininger)
20
+ * Removed override for integer and float (thanks to @fwininger)
21
+ * Added rubocop to development environment (thanks to @fwininger)
22
+
23
+ ### Notes
24
+ Adding CvssSuite module everywhere means it’s no longer possible to access a class without it. Since this only affects the undocumented and ‚internal‘ classes this should not affect you. If you’re using them, stop it.
25
+
26
+ Still works:
27
+
28
+ ```ruby
29
+ cvss = CvssSuite.new('string')
30
+ ```
31
+
32
+ Won’t work anymore (without any code change):
33
+
34
+ ```ruby
35
+ cvss = Cvss31.new('string')
36
+ ```
37
+
38
+ This would need to be CvssSuite::Cvss31.new('string') to work. Or you could include the whole namespace.
39
+
40
+ ## [1.2.0] - 2019-07-02
41
+
42
+ ### Notes
43
+ Because version 2.0 of this gem will include breaking changes, please make sure to include this gem in your gemfile as shown below to not automatically update to version 2.0.
44
+
45
+ ```ruby
46
+ gem 'cvss-suite', '~> 1.2'
47
+ ```
48
+
49
+ ### Improvements
50
+ * Added Severity
51
+ * Added CVSS 3.1
52
+ * CVSS 3.0 vectors now return 3.0 instead of 3 as version
53
+
54
+ ### Changes in CVSS 3.1 [Source] (https://www.first.org/cvss/v3.1/user-guide)
55
+ * The Temporal Score for all vulnerabilities which have a Base Score of 2.5, 5.0 or 10.0, Exploit Code Maturity (E) of High (H), Remediation Level (RL) of Unavailable (U) and Report Confidence (RC) of Unknown (U) is 0.1 lower in CVSS v3.1 than for 3.0.
56
+ * Some combinations of metrics have Environmental Scores that differ when scored with CVSS v3.1 rather than v3.0. This is due to a combination of the redefinition of Roundup and the change to the ModifiedImpact sub-formula. Less than 7% of metric combinations are 0.1 higher in CVSS v3.1 than v3.0, and less than 1% are 0.1 lower. No Environmental Scores differ by more than 0.1.
57
+ * Other implementations of the CVSS formulas may see different scoring changes between CVSS v3.0 and v3.1 if they previously generated different CVSS v3.0 scores due to the problems that the CVSS v3.1 formula changes are intended to fix.
58
+
59
+ ## [1.1.2] - 2018-12-28
60
+
61
+ ### Fixes
62
+ Replaced Fixnum by Integer to improve compatibility with newer versions of Ruby.
63
+
64
+ ### Improvements
65
+ Added example for CVSS v3 to README.
66
+
5
67
  ## [1.1.1] - 2018-10-18
6
68
 
7
69
  ### Fixes
@@ -0,0 +1,24 @@
1
+ ## Proposed changes
2
+
3
+ Describe the big picture of your changes here to communicate to the maintainers why we should accept this pull request. If it fixes a bug or resolves a feature request, be sure to link to that issue.
4
+
5
+ ## Types of changes
6
+
7
+ What types of changes does your code introduce to CvssSuite?
8
+ _Put an `x` in the boxes that apply_
9
+
10
+ - [ ] Bugfix (non-breaking change which fixes an issue)
11
+ - [ ] New feature (non-breaking change which adds functionality)
12
+ - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
13
+
14
+ ## Checklist
15
+
16
+ _Put an `x` in the boxes that apply. You can also fill these out after creating the PR._
17
+
18
+ - [ ] Unit tests pass locally with my changes
19
+ - [ ] I have added tests that prove my fix is effective or that my feature works
20
+ - [ ] I have added necessary documentation (if appropriate)
21
+
22
+ ## Further comments
23
+
24
+ If this is a relatively large or complex change, kick off the discussion by explaining why you chose the solution you did and what alternatives you considered, etc...
data/README.md CHANGED
@@ -1,13 +1,20 @@
1
- # CvssSuite
1
+ # CvssSuite for Ruby
2
2
 
3
3
  [![Gem Version](http://img.shields.io/gem/v/cvss-suite.svg)](https://rubygems.org/gems/cvss-suite)
4
4
  [![Ruby Version](https://img.shields.io/badge/Ruby-2.x-brightgreen.svg)](https://rubygems.org/gems/cvss-suite)
5
- [![Cvss Support](https://img.shields.io/badge/CVSS-v2-brightgreen.svg)](https://www.first.org/cvss/cvss-v2-guide.pdf)
6
- [![Cvss Support](https://img.shields.io/badge/CVSS-v3.0-brightgreen.svg)](https://www.first.org/cvss/cvss-v3-guide.pdf)
5
+ [![Cvss Support](https://img.shields.io/badge/CVSS-v2-brightgreen.svg)](https://www.first.org/cvss/v2/guide)
6
+ [![Cvss Support](https://img.shields.io/badge/CVSS-v3.0-brightgreen.svg)](https://www.first.org/cvss/v3.0/user-guide)
7
+ [![Cvss Support](https://img.shields.io/badge/CVSS-v3.1-brightgreen.svg)](https://www.first.org/cvss/v3.1/user-guide)
8
+ ![RSpec](https://github.com/siemens/cvss-suite/workflows/RSpec/badge.svg)
7
9
 
8
10
  This Ruby gem helps you to process the vector of the [**Common Vulnerability Scoring System**](https://www.first.org/cvss/specification-document).
9
11
  Besides calculating the Base, Temporal and Environmental Score, you are able to extract the selected option.
10
12
 
13
+ ## :warning: End of life :warning:
14
+
15
+ This version of the gem is no longer supported, please update to a higher version.
16
+ Please read the [changelog of 2.0.0](https://github.com/siemens/cvss-suite/blob/master/CHANGES.md#200---2020-05-10) for breaking changes.
17
+
11
18
  ## Installation
12
19
 
13
20
  Add this line to your application's Gemfile:
@@ -29,11 +36,26 @@ Or install it yourself as:
29
36
  ```ruby
30
37
  require 'cvss_suite'
31
38
 
39
+ 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')
40
+
41
+ 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'
42
+ version = cvss3.version # 3.0
43
+ valid = cvss3.valid? # true
44
+ severity = cvss3.severity # 'High'
45
+
46
+ 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')
47
+
48
+ vector = cvss31.vector # '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'
49
+ version = cvss31.version # 3.1
50
+ valid = cvss31.valid? # true
51
+ severity = cvss31.severity # 'Medium'
52
+
32
53
  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')
33
54
 
34
- 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'
35
- version = cvss.version # 2
36
- valid = cvss.valid? # true
55
+ 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'
56
+ version = cvss.version # 2
57
+ valid = cvss.valid? # true
58
+ severity = cvss.severity # 'Low'
37
59
 
38
60
  # Scores
39
61
  base_score = cvss.base_score # 4.9
@@ -67,7 +89,7 @@ valid = cvss.valid? # false
67
89
  version = cvss.version # will throw CvssSuite::Errors::InvalidVector: Vector is not valid!
68
90
  cvss.base_score # will throw CvssSuite::Errors::InvalidVector: Vector is not valid!
69
91
 
70
- CvssSuite.new() # will throw a ArgumentError
92
+ CvssSuite.new() # will throw a ArgumentError
71
93
 
72
94
  cvss = CvssSuite.new('AV:N/AC:P/C:P/AV:U/RL:OF/RC:C') # invalid vector, authentication is missing
73
95
  version = cvss.version # 2
@@ -81,11 +103,17 @@ Properties (Access Vector, Remediation Level, etc) do have a position attribute,
81
103
 
82
104
  ## Known Issues
83
105
 
84
- Currently it is not possible to leave a attribute blank instead of ND/X. If you don't have a value for a attribute, please use ND/X instead.
106
+ Currently it is not possible to leave an attribute blank instead of ND/X. If you don't have a value for an attribute, please use ND/X instead.
107
+
108
+ There is a possibility of implementations generating different scores (+/- 0,1) due to small floating-point inaccuracies. This can happen due to differences in floating point arithmetic between different languages and hardware platforms.
109
+
110
+ ## Changelog
85
111
 
86
- Because the documentation isn't clear on how to calculate the score if Modified Scope (CVSS 3.0 Environmental) is not defined, Modified Scope has to have a valid value (S/U).
112
+ [Click here to see all changes.](https://github.com/siemens/cvss-suite/blob/1.x/CHANGES.md)
87
113
 
88
114
  ## Contributing
89
115
 
90
116
  Bug reports and pull requests are welcome on GitHub at https://github.com/siemens/cvss-suite. This project is intended to be a safe, welcoming space for collaboration.
91
117
 
118
+ ## References
119
+ [CvssSuite for .NET](https://github.com/oliverhamboerger/CvssSuite)
@@ -0,0 +1 @@
1
+ theme: jekyll-theme-cayman
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require "bundler/setup"
4
- require "cvss_suite"
3
+ require 'bundler/setup'
4
+ require 'cvss_suite'
5
5
 
6
6
  # You can add fixtures and/or initialization code here to make experimenting
7
7
  # with your gem easier. You can also use a different console, if you like.
@@ -10,5 +10,5 @@ require "cvss_suite"
10
10
  # require "pry"
11
11
  # Pry.start
12
12
 
13
- require "irb"
13
+ require 'irb'
14
14
  IRB.start