cvss-suite 1.2.0 → 2.0.2

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: 6aacfd5bb6fb48310c6c6c5cb2821a247971ef6115cb7c4c86dddb4335d8dafd
4
- data.tar.gz: 5c881abb0186de84cb10596ff12333a9e8934ed290b8fe762471aaf82f008177
3
+ metadata.gz: f109a2e3d49b66723f39c092692b3cabfa75d829d8ef3f0e07cf9d0d238a3755
4
+ data.tar.gz: 41660286d0173fa19c37dd49b43f4efc5fc1db025ae6a46741baf0694b5199d3
5
5
  SHA512:
6
- metadata.gz: 293c41865c1905f2ca44a34d7298813484312af93deb77f443411222df307df80f4a40781af2137b05f561e66fd8317196b5a8512ea82c21d565d4eb221492ff
7
- data.tar.gz: 3c33b092a180ca728add5bcb4380881789f98652cf5476eb841ee23ee8b38a72e56cd7be916cfb297aa644d470830280826086561850c4625228a06e43bb82f2
6
+ metadata.gz: c567e0730cf9e4ef3e2e85a5c1fa35a9b949c59ed278a968bbf336732f1229cbcfbd84c34e67256a91a6de058a71b13275cb4d8eefdbaa2c416b18e106aac7ff
7
+ data.tar.gz: d883de3fdc12def5106855a221a535751c9846104ee37a6ecbe8a391a9e3f59b752696c7e0fd128b0dcf8fbedf60bdaa6a0c3d1d1a625c71204555133a4e365b
@@ -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: Install gems
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
@@ -0,0 +1,21 @@
1
+ name: Rubocop
2
+
3
+ on: [push,pull_request]
4
+
5
+ jobs:
6
+ build:
7
+
8
+ runs-on: ubuntu-latest
9
+
10
+ steps:
11
+ - uses: actions/checkout@v2
12
+ - name: Set up Ruby 2.7
13
+ uses: actions/setup-ruby@v1
14
+ with:
15
+ ruby-version: 2.7
16
+ - name: Install gems
17
+ run: |
18
+ gem install bundler -v ">= 1.10"
19
+ gem install rubocop
20
+ - name: Run checks
21
+ run: rubocop -F --fail-level C -f s
@@ -1,2 +1,48 @@
1
+ inherit_from: .rubocop_todo.yml
2
+
3
+ AllCops:
4
+ TargetRubyVersion: 2.4
5
+ SuggestExtensions: false
6
+
1
7
  Metrics/LineLength:
2
- Max: 120
8
+ Max: 120
9
+ Exclude:
10
+ - 'lib/cvss_suite/cvss3/cvss3_environmental.rb'
11
+ - 'lib/cvss_suite/cvss31/cvss31_environmental.rb'
12
+
13
+ Metrics/ClassLength:
14
+ Exclude:
15
+ - 'lib/cvss_suite/cvss3/cvss3_environmental.rb'
16
+ - 'lib/cvss_suite/cvss31/cvss31_environmental.rb'
17
+
18
+ Metrics/MethodLength:
19
+ Exclude:
20
+ - 'lib/cvss_suite/cvss3/cvss3_environmental.rb'
21
+ - 'lib/cvss_suite/cvss31/cvss31_environmental.rb'
22
+
23
+ Metrics/BlockLength:
24
+ Exclude:
25
+ - 'spec/cvss2/cvss2_spec.rb'
26
+ - 'spec/cvss3/cvss3_spec.rb'
27
+ - 'spec/cvss31/cvss31_spec.rb'
28
+
29
+ Style/IfUnlessModifier:
30
+ Exclude:
31
+ - 'lib/cvss_suite/cvss3/cvss3_environmental.rb'
32
+ - 'lib/cvss_suite/cvss31/cvss31_environmental.rb'
33
+
34
+ Style/GuardClause:
35
+ Exclude:
36
+ - 'lib/cvss_suite/cvss3/cvss3_environmental.rb'
37
+ - 'lib/cvss_suite/cvss31/cvss31_environmental.rb'
38
+
39
+ Style/ConditionalAssignment:
40
+ Exclude:
41
+ - 'lib/cvss_suite/cvss3/cvss3_environmental.rb'
42
+ - 'lib/cvss_suite/cvss31/cvss31_environmental.rb'
43
+
44
+ Style/FrozenStringLiteralComment:
45
+ Enabled: false
46
+
47
+ Style/AsciiComments:
48
+ Enabled: false
@@ -0,0 +1,59 @@
1
+ # This configuration was generated by
2
+ # `rubocop --auto-gen-config`
3
+ # on 2020-05-05 17:47:10 +0200 using RuboCop version 0.82.0.
4
+ # The point is for the user to remove these configuration records
5
+ # one by one as the offenses are removed from the code base.
6
+ # Note that changes in the inspected code, or installation of new
7
+ # versions of RuboCop, may require this file to be generated again.
8
+
9
+ # Offense count: 1
10
+ Lint/IneffectiveAccessModifier:
11
+ Exclude:
12
+ - 'lib/cvss_suite.rb'
13
+
14
+ # Offense count: 1
15
+ # Configuration parameters: ContextCreatingMethods, MethodCreatingMethods.
16
+ Lint/UselessAccessModifier:
17
+ Exclude:
18
+ - 'lib/cvss_suite.rb'
19
+
20
+ # Offense count: 8
21
+ # Configuration parameters: IgnoredMethods.
22
+ Metrics/AbcSize:
23
+ Max: 35
24
+
25
+ # Offense count: 5
26
+ # Configuration parameters: CountComments, ExcludedMethods.
27
+ # ExcludedMethods: refine
28
+ Metrics/BlockLength:
29
+ Max: 58
30
+
31
+ # Offense count: 2
32
+ # Configuration parameters: CountComments.
33
+ Metrics/ClassLength:
34
+ Max: 101
35
+
36
+ # Offense count: 1
37
+ # Configuration parameters: IgnoredMethods.
38
+ Metrics/CyclomaticComplexity:
39
+ Max: 9
40
+
41
+ # Offense count: 13
42
+ # Configuration parameters: CountComments, ExcludedMethods.
43
+ Metrics/MethodLength:
44
+ Max: 63
45
+
46
+ # Offense count: 1
47
+ # Configuration parameters: CountKeywordArgs.
48
+ Metrics/ParameterLists:
49
+ Max: 6
50
+
51
+ # Offense count: 1
52
+ # Configuration parameters: IgnoredMethods.
53
+ Metrics/PerceivedComplexity:
54
+ Max: 10
55
+
56
+ # Offense count: 1
57
+ Naming/AccessorMethodName:
58
+ Exclude:
59
+ - 'lib/cvss_suite/cvss_property.rb'
data/CHANGES.md CHANGED
@@ -2,6 +2,45 @@
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
+ ## [2.0.2] - 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
+ ## [2.0.1] - 2020-07-19
12
+
13
+ ### Fixes
14
+ Fixed an error that resulted in incorrect environmental score if modified attributes were not defined.
15
+
16
+ ## [2.0.0] - 2020-05-10
17
+
18
+ ### Breaking Changes
19
+ * Ruby >= 2.4 is now required
20
+ * Renamed choice/choices to value/values
21
+
22
+ ### Improvements
23
+ * Added CvssSuite module to every class (thanks to @fwininger)
24
+ * Removed override for integer and float (thanks to @fwininger)
25
+ * Added rubocop to development environment (thanks to @fwininger)
26
+
27
+ ### Notes
28
+ 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.
29
+
30
+ Still works:
31
+
32
+ ```ruby
33
+ cvss = CvssSuite.new('string')
34
+ ```
35
+
36
+ Won’t work anymore (without any code change):
37
+
38
+ ```ruby
39
+ cvss = Cvss31.new('string')
40
+ ```
41
+
42
+ This would need to be CvssSuite::Cvss31.new('string') to work. Or you could include the whole namespace.
43
+
5
44
  ## [1.2.0] - 2019-07-02
6
45
 
7
46
  ### Notes
@@ -71,4 +110,4 @@ Tried to fix an error. It turned out to be a local problem. Due to this I increa
71
110
 
72
111
  ## [1.0.0] - 2016-04-15
73
112
  ### Initial release
74
- First release of this gem.
113
+ First release of this gem.
data/README.md CHANGED
@@ -1,10 +1,11 @@
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
- [![Ruby Version](https://img.shields.io/badge/Ruby-2.x-brightgreen.svg)](https://rubygems.org/gems/cvss-suite)
4
+ [![Ruby Version](https://img.shields.io/badge/Ruby-2.4-brightgreen.svg)](https://rubygems.org/gems/cvss-suite)
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
+ [![RSpec](https://github.com/siemens/cvss-suite/workflows/RSpec/badge.svg)](https://github.com/siemens/cvss-suite/actions)
8
9
 
9
10
  This Ruby gem helps you to process the vector of the [**Common Vulnerability Scoring System**](https://www.first.org/cvss/specification-document).
10
11
  Besides calculating the Base, Temporal and Environmental Score, you are able to extract the selected option.
@@ -24,6 +25,10 @@ And then execute:
24
25
  Or install it yourself as:
25
26
 
26
27
  $ gem install cvss-suite
28
+
29
+ ## Version 1.x
30
+
31
+ If you are still using CvssSuite 1.x please refer to the [specific branch](https://github.com/siemens/cvss-suite/tree/1.x) for documentation and changelog.
27
32
 
28
33
  ## Usage
29
34
 
@@ -61,15 +66,15 @@ overall_score = cvss.overall_score # 3.2
61
66
  access_vector = cvss.base.access_vector.name # 'Access Vector'
62
67
  remediation_level = cvss.temporal.remediation_level.name # 'Remediation Level'
63
68
 
64
- access_vector.choices.each do |choice|
65
- choice[:name] # 'Local', 'Adjacent Network', 'Network'
66
- choice[:abbreviation] # 'L', 'A', 'N'
67
- choice[:selected] # false, true, false
69
+ access_vector.values.each do |value|
70
+ value[:name] # 'Local', 'Adjacent Network', 'Network'
71
+ value[:abbreviation] # 'L', 'A', 'N'
72
+ value[:selected] # false, true, false
68
73
  end
69
74
 
70
75
  # Selected options
71
- cvss.base.access_vector.selected_choice[:name] # Adjacent Network
72
- cvss.temporal.remediation_level.selected_choice[:name] # Temporary Fix
76
+ cvss.base.access_vector.selected_value[:name] # Adjacent Network
77
+ cvss.temporal.remediation_level.selected_value[:name] # Temporary Fix
73
78
 
74
79
  # Exceptions
75
80
 
@@ -99,15 +104,15 @@ Properties (Access Vector, Remediation Level, etc) do have a position attribute,
99
104
 
100
105
  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.
101
106
 
102
- 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).
103
-
104
107
  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.
105
108
 
106
109
  ## Changelog
107
110
 
108
- [Click here to see all changes.](https://raw.githubusercontent.com/siemens/cvss-suite/master/CHANGES.md)
111
+ [Click here to see all changes.](https://github.com/siemens/cvss-suite/blob/master/CHANGES.md)
109
112
 
110
113
  ## Contributing
111
114
 
112
115
  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.
113
116
 
117
+ ## References
118
+ [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
@@ -9,7 +9,8 @@
9
9
  # See the LICENSE.md file in the top-level directory.
10
10
 
11
11
  # coding: utf-8
12
- lib = File.expand_path('../lib', __FILE__)
12
+
13
+ lib = File.expand_path('lib', __dir__)
13
14
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
14
15
  require 'cvss_suite/version'
15
16
 
@@ -17,24 +18,23 @@ Gem::Specification.new do |spec|
17
18
  spec.name = 'cvss-suite'
18
19
  spec.version = CvssSuite::VERSION
19
20
  spec.license = 'MIT'
20
- spec.authors = ["Oliver Hamboerger"]
21
- spec.email = ["oliver.hamboerger@siemens.com"]
21
+ spec.authors = ['Oliver Hamboerger']
22
+ spec.email = ['oliver.hamboerger@siemens.com']
22
23
 
23
- spec.summary = %q{Ruby gem for processing cvss vectors.}
24
- spec.description = %q{This Ruby gem helps you to process the vector of the Common Vulnerability Scoring System (https://www.first.org/cvss/specification-document).
25
- Besides calculating the Base, Temporal and Environmental Score, you are able to extract the selected option.}
26
- spec.homepage = "https://siemens.github.io/cvss-suite/"
24
+ 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.'
27
+ spec.homepage = 'https://siemens.github.io/cvss-suite/'
27
28
 
28
- spec.required_ruby_version = '>= 2.0.0'
29
+ spec.required_ruby_version = '>= 2.4.0'
29
30
  spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
30
31
  spec.bindir = 'exe'
31
32
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
32
33
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
33
- spec.require_paths = ["lib"]
34
+ spec.require_paths = ['lib']
34
35
 
35
- spec.add_development_dependency "bundler", "~> 1.10"
36
- spec.add_development_dependency "rspec", "~> 3.4"
37
- spec.add_development_dependency "rspec-its", "~> 1.2"
38
- spec.add_development_dependency "rdoc", "~> 4.2"
39
- spec.add_development_dependency "simplecov", "~> 0.11.2"
36
+ spec.add_development_dependency 'bundler', '>= 1.10'
37
+ spec.add_development_dependency 'rspec', '~> 3.4'
38
+ spec.add_development_dependency 'rspec-its', '~> 1.2'
39
+ spec.add_development_dependency 'simplecov', '~> 0.18'
40
40
  end
@@ -12,33 +12,32 @@ require 'cvss_suite/cvss2/cvss2'
12
12
  require 'cvss_suite/cvss3/cvss3'
13
13
  require 'cvss_suite/cvss31/cvss31'
14
14
  require 'cvss_suite/version'
15
- require 'cvss_suite/helpers/extensions'
16
15
  require 'cvss_suite/errors'
17
16
  require 'cvss_suite/invalid_cvss'
18
17
 
19
18
  ##
20
19
  # Module of this gem.
21
-
22
20
  module CvssSuite
23
21
  CVSS_VECTOR_BEGINNINGS = [
24
- {:string => 'AV:', :version => 2},
25
- {:string => 'CVSS:3.0/', :version => 3.0},
26
- {:string => 'CVSS:3.1/', :version => 3.1}
27
- ]
22
+ { string: 'AV:', version: 2 },
23
+ { string: '(AV:', version: 2 },
24
+ { string: 'CVSS:3.0/', version: 3.0 },
25
+ { string: 'CVSS:3.1/', version: 3.1 }
26
+ ].freeze
28
27
 
29
28
  ##
30
29
  # Returns a CVSS class by a +vector+.
31
-
32
30
  def self.new(vector)
33
31
  return InvalidCvss.new unless vector.is_a? String
32
+
34
33
  @vector_string = vector
35
34
  case version
36
35
  when 2
37
- Cvss2.new(@vector_string, version)
36
+ Cvss2.new(@vector_string)
38
37
  when 3.0
39
- Cvss3.new(@vector_string, version)
38
+ Cvss3.new(@vector_string)
40
39
  when 3.1
41
- Cvss31.new(@vector_string, version)
40
+ Cvss31.new(@vector_string)
42
41
  else
43
42
  InvalidCvss.new
44
43
  end
@@ -48,10 +47,7 @@ module CvssSuite
48
47
 
49
48
  def self.version
50
49
  CVSS_VECTOR_BEGINNINGS.each do |beginning|
51
- if @vector_string.start_with? beginning[:string]
52
- return beginning[:version]
53
- end
50
+ return beginning[:version] if @vector_string.start_with? beginning[:string]
54
51
  end
55
52
  end
56
-
57
53
  end
@@ -8,118 +8,116 @@
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 any CVSS vector. Do not instantiate this class!
13
-
14
- class Cvss
15
-
16
- ##
17
- # Metric of a CVSS vector.
18
-
19
- attr_reader :base, :temporal, :environmental
20
-
21
- ##
22
- # Returns version of current CVSS vector.
23
-
24
- attr_reader :version
25
-
26
- ##
27
- # Returns the vector itself.
28
-
29
- attr_reader :vector
30
-
31
- ##
32
- # Creates a new CVSS vector by a +vector+ and a +version+.
33
- #
34
- # Raises an exception if it is called on Cvss class.
35
-
36
- def initialize(vector, version)
37
- raise CvssSuite::Errors::InvalidParentClass, 'Do not instantiate this class!' if self.class == Cvss
38
- @version = version
39
- @vector = vector
40
- @properties = []
41
- extract_metrics
42
- init_metrics
43
- end
44
-
11
+ module CvssSuite
45
12
  ##
46
- # Returns if CVSS vector is valid.
13
+ # This class represents any CVSS vector. Do not instantiate this class!
14
+ class Cvss
15
+ ##
16
+ # Metric of a CVSS vector.
17
+ attr_reader :base, :temporal, :environmental
18
+
19
+ ##
20
+ # Returns the vector itself.
21
+ attr_reader :vector
22
+
23
+ ##
24
+ # Creates a new CVSS vector by a +vector+.
25
+ #
26
+ # Raises an exception if it is called on Cvss class.
27
+ def initialize(vector)
28
+ raise CvssSuite::Errors::InvalidParentClass, 'Do not instantiate this class!' if instance_of? Cvss
29
+
30
+ @vector = vector
31
+ @properties = []
32
+ extract_metrics
33
+ init_metrics
34
+ end
47
35
 
48
- def valid?
49
- if @amount_of_properties == required_amount_of_properties
36
+ ##
37
+ # Returns if CVSS vector is valid.
38
+ def valid?
39
+ if @amount_of_properties == required_amount_of_properties
50
40
  base = @base.valid?
51
41
  temporal = @base.valid? && @temporal.valid?
52
42
  environmental = @base.valid? && @environmental.valid?
53
43
  full = @base.valid? && @temporal.valid? && @environmental.valid?
54
44
  base || temporal || environmental || full
55
- else
56
- false
45
+ else
46
+ false
47
+ end
57
48
  end
58
- end
59
49
 
60
- ##
61
- # Returns the severity of the CVSS vector.
62
-
63
- def severity
64
- check_validity
65
-
66
- score = overall_score
67
-
68
- if 0.0 == score
69
- "None"
70
- elsif (0.1..3.9).include? score
71
- "Low"
72
- elsif (4.0..6.9).include? score
73
- "Medium"
74
- elsif (7.0..8.9).include? score
75
- "High"
76
- elsif (9.0..10.0).include? score
77
- "Critical"
78
- else
79
- "None"
50
+ ##
51
+ # Returns the severity of the CVSS vector.
52
+ def severity
53
+ check_validity
54
+
55
+ score = overall_score
56
+
57
+ if score <= 0.0
58
+ 'None'
59
+ elsif (0.1..3.9).cover? score
60
+ 'Low'
61
+ elsif (4.0..6.9).cover? score
62
+ 'Medium'
63
+ elsif (7.0..8.9).cover? score
64
+ 'High'
65
+ elsif (9.0..10.0).cover? score
66
+ 'Critical'
67
+ else
68
+ 'None'
69
+ end
80
70
  end
81
- end
82
71
 
83
- ##
84
- # Returns the Overall Score of the CVSS vector.
72
+ ##
73
+ # Returns the Overall Score of the CVSS vector.
74
+ def overall_score
75
+ check_validity
76
+ return temporal_score if @temporal.valid? && !@environmental.valid?
77
+ return environmental_score if @environmental.valid?
85
78
 
86
- def overall_score
87
- check_validity
88
- return temporal_score if @temporal.valid? && !@environmental.valid?
89
- return environmental_score if @environmental.valid?
90
- base_score
91
- end
79
+ base_score
80
+ end
92
81
 
93
- private
82
+ private
94
83
 
95
- def extract_metrics
96
- properties = prepared_vector.split('/')
97
- @amount_of_properties = properties.size
98
- properties.each_with_index do |property, index|
99
- property = property.split(':')
100
- @properties.push({ name: property[0], selected: property[1], position: index })
84
+ def extract_metrics
85
+ properties = prepared_vector.split('/')
86
+ @amount_of_properties = properties.size
87
+ properties.each_with_index do |property, index|
88
+ property = property.split(':')
89
+ @properties.push({ name: property[0], selected: property[1], position: index })
90
+ end
101
91
  end
102
- end
103
-
104
- def check_validity
105
- raise CvssSuite::Errors::InvalidVector, 'Vector is not valid!' unless valid?
106
- end
107
92
 
108
- def prepared_vector
109
- start_of_vector = @vector.index('AV')
93
+ def check_validity
94
+ raise CvssSuite::Errors::InvalidVector, 'Vector is not valid!' unless valid?
95
+ end
110
96
 
111
- if start_of_vector.nil?
112
- String.new
113
- else
114
- @vector[start_of_vector..-1]
97
+ def prepared_vector
98
+ start_of_vector = @vector.index('AV')
99
+
100
+ if start_of_vector.nil?
101
+ ''
102
+ elsif start_of_vector == 1
103
+ match_array = @vector.scan(/\((?>[^)(]+|\g<0>)*\)/)
104
+ if match_array.length == 1 && match_array[0] == @vector
105
+ @vector.slice!(0)
106
+ @vector.slice!(@vector.length - 1)
107
+ @vector
108
+ else
109
+ ''
110
+ end
111
+ else
112
+ @vector[start_of_vector..-1]
113
+ end
115
114
  end
116
- end
117
115
 
118
- def required_amount_of_properties
119
- total = @base.count if @base.valid?
120
- total += @temporal.count if @temporal.valid?
121
- total += @environmental.count if @environmental.valid?
122
- total ||= 0
116
+ def required_amount_of_properties
117
+ total = @base.count if @base.valid?
118
+ total += @temporal.count if @temporal.valid?
119
+ total += @environmental.count if @environmental.valid?
120
+ total || 0
121
+ end
123
122
  end
124
-
125
- end
123
+ end