Skip to content

Commit 1cb5093

Browse files
authored
Merge pull request #34 from 0llirocks/33-cvss-prefix-is-missing-in-v310
33 cvss prefix is missing in v310
2 parents 48e844d + 468d62e commit 1cb5093

File tree

8 files changed

+72
-12
lines changed

8 files changed

+72
-12
lines changed

CHANGES.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22
All notable changes to this project will be documented in this file.
33
This project adheres to [Semantic Versioning](http://semver.org/).
44

5+
## [3.1.1] - 2023-10-15
6+
7+
### Fixes
8+
* CVSS prefix is missing in v3.1.0. Fixes [#33](https://github.com/0llirocks/cvss-suite/issues/33)
9+
510
## [3.1.0] - 2022-09-27
611

712
### Fixes

lib/cvss_suite/cvss.rb

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# CVSS-Suite, a Ruby gem to manage the CVSS vector
22
#
33
# Copyright (c) 2016-2022 Siemens AG
4-
# Copyright (c) 2022 0llirocks
4+
# Copyright (c) 2022-2023 0llirocks
55
#
66
# Authors:
77
# 0llirocks <http://0lli.rocks>
@@ -17,10 +17,6 @@ class Cvss
1717
# Metric of a CVSS vector.
1818
attr_reader :base, :temporal, :environmental
1919

20-
##
21-
# Returns the vector itself.
22-
attr_reader :vector
23-
2420
##
2521
# Creates a new CVSS vector by a +vector+.
2622
#
@@ -80,6 +76,12 @@ def overall_score
8076
base_score
8177
end
8278

79+
##
80+
# Returns the vector itself.
81+
def vector
82+
@vector.to_s
83+
end
84+
8385
private
8486

8587
def extract_metrics

lib/cvss_suite/cvss3/cvss3.rb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# CVSS-Suite, a Ruby gem to manage the CVSS vector
22
#
33
# Copyright (c) 2016-2022 Siemens AG
4-
# Copyright (c) 2022 0llirocks
4+
# Copyright (c) 2022-2023 0llirocks
55
#
66
# Authors:
77
# 0llirocks <http://0lli.rocks>
@@ -45,6 +45,12 @@ def environmental_score
4545
Cvss3Helper.round_up(@environmental.score(@base, @temporal))
4646
end
4747

48+
##
49+
# Returns the vector itself.
50+
def vector
51+
"#{CvssSuite::CVSS_VECTOR_BEGINNINGS.find { |beginning| beginning[:version] == version }[:string]}#{@vector}"
52+
end
53+
4854
private
4955

5056
def init_metrics

lib/cvss_suite/cvss31/cvss31.rb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# CVSS-Suite, a Ruby gem to manage the CVSS vector
22
#
33
# Copyright (c) 2019-2022 Siemens AG
4-
# Copyright (c) 2022 0llirocks
4+
# Copyright (c) 2022-2023 0llirocks
55
#
66
# Authors:
77
# 0llirocks <http://0lli.rocks>
@@ -50,6 +50,12 @@ def environmental_score
5050
Cvss31Helper.round_up(@environmental.score(@base, @temporal))
5151
end
5252

53+
##
54+
# Returns the vector itself.
55+
def vector
56+
"#{CvssSuite::CVSS_VECTOR_BEGINNINGS.find { |beginning| beginning[:version] == version }[:string]}#{@vector}"
57+
end
58+
5359
private
5460

5561
def init_metrics

lib/cvss_suite/version.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# CVSS-Suite, a Ruby gem to manage the CVSS vector
22
#
33
# Copyright (c) 2016-2022 Siemens AG
4-
# Copyright (c) 2022 0llirocks
4+
# Copyright (c) 2022-2023 0llirocks
55
#
66
# Authors:
77
# 0llirocks <http://0lli.rocks>
@@ -10,5 +10,5 @@
1010
# See the LICENSE.md file in the top-level directory.
1111

1212
module CvssSuite
13-
VERSION = '3.1.0'.freeze
13+
VERSION = '3.1.1'.freeze
1414
end

spec/cvss2/cvss2_spec.rb

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# CVSS-Suite, a Ruby gem to manage the CVSS vector
22
#
33
# Copyright (c) 2016-2022 Siemens AG
4-
# Copyright (c) 2022 0llirocks
4+
# Copyright (c) 2022-2023 0llirocks
55
#
66
# Authors:
77
# 0llirocks <http://0lli.rocks>
@@ -137,4 +137,15 @@
137137
end
138138
end
139139
end
140+
141+
describe 'correct vector' do
142+
[
143+
['AV:N/AC:L/Au:N/C:P/I:P/A:P', 'AV:N/AC:L/Au:N/C:P/I:P/A:P'],
144+
['(AV:N/AC:L/Au:N/C:P/I:P/A:P)', 'AV:N/AC:L/Au:N/C:P/I:P/A:P']
145+
].each do |vector|
146+
it "'#{vector[0]}' is expected to return '#{vector[1]}'" do
147+
expect(CvssSuite.new(vector[0]).vector).to eq(vector[1])
148+
end
149+
end
150+
end
140151
end

spec/cvss3/cvss3_spec.rb

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# CVSS-Suite, a Ruby gem to manage the CVSS vector
22
#
33
# Copyright (c) 2016-2022 Siemens AG
4-
# Copyright (c) 2022 0llirocks
4+
# Copyright (c) 2022-2023 0llirocks
55
#
66
# Authors:
77
# 0llirocks <http://0lli.rocks>
@@ -160,4 +160,19 @@
160160

161161
it_behaves_like 'a invalid cvss vector with version', 3.0
162162
end
163+
164+
describe 'correct vector' do
165+
[
166+
['CVSS:3.0/AV:L/AC:H/PR:L/UI:R/S:U/C:L/I:L/A:L', 'CVSS:3.0/AV:L/AC:H/PR:L/UI:R/S:U/C:L/I:L/A:L'],
167+
['CVSS:3.0/A:L/AC:H/PR:L/UI:R/S:U/C:L/I:L/AV:L', 'CVSS:3.0/A:L/AC:H/PR:L/UI:R/S:U/C:L/I:L/AV:L'],
168+
[
169+
'CVSS:3.0/AV:P/AC:L/PR:H/UI:N/S:C/C:N/I:L/A:H/E:X/RL:T/RC:C/CR:M/IR:L/AR:H/MAV:X/MAC:X/MPR:X/MUI:X/MS:X/MC:X/MI:X/MA:X', # rubocop:disable Layout/LineLength
170+
'CVSS:3.0/AV:P/AC:L/PR:H/UI:N/S:C/C:N/I:L/A:H/E:X/RL:T/RC:C/CR:M/IR:L/AR:H/MAV:X/MAC:X/MPR:X/MUI:X/MS:X/MC:X/MI:X/MA:X' # rubocop:disable Layout/LineLength
171+
]
172+
].each do |vector|
173+
it "'#{vector[0]}' is expected to return '#{vector[1]}'" do
174+
expect(CvssSuite.new(vector[0]).vector).to eq(vector[1])
175+
end
176+
end
177+
end
163178
end

spec/cvss31/cvss31_spec.rb

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# CVSS-Suite, a Ruby gem to manage the CVSS vector
22
#
33
# Copyright (c) 2016-2022 Siemens AG
4-
# Copyright (c) 2022 0llirocks
4+
# Copyright (c) 2022-2023 0llirocks
55
#
66
# Authors:
77
# 0llirocks <http://0lli.rocks>
@@ -159,4 +159,19 @@
159159

160160
it_behaves_like 'a invalid cvss vector with version', 3.1
161161
end
162+
163+
describe 'correct vector' do
164+
[
165+
['CVSS:3.1/AV:L/AC:H/PR:L/UI:R/S:U/C:L/I:L/A:L', 'CVSS:3.1/AV:L/AC:H/PR:L/UI:R/S:U/C:L/I:L/A:L'],
166+
['CVSS:3.1/A:L/AC:H/PR:L/UI:R/S:U/C:L/I:L/AV:L', 'CVSS:3.1/A:L/AC:H/PR:L/UI:R/S:U/C:L/I:L/AV:L'],
167+
[
168+
'CVSS:3.1/AV:P/AC:L/PR:H/UI:N/S:C/C:N/I:L/A:H/E:X/RL:T/RC:C/CR:M/IR:L/AR:H/MAV:X/MAC:X/MPR:X/MUI:X/MS:X/MC:X/MI:X/MA:X', # rubocop:disable Layout/LineLength
169+
'CVSS:3.1/AV:P/AC:L/PR:H/UI:N/S:C/C:N/I:L/A:H/E:X/RL:T/RC:C/CR:M/IR:L/AR:H/MAV:X/MAC:X/MPR:X/MUI:X/MS:X/MC:X/MI:X/MA:X' # rubocop:disable Layout/LineLength
170+
]
171+
].each do |vector|
172+
it "'#{vector[0]}' is expected to return '#{vector[1]}'" do
173+
expect(CvssSuite.new(vector[0]).vector).to eq(vector[1])
174+
end
175+
end
176+
end
162177
end

0 commit comments

Comments
 (0)