tests.test_cvss   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 12
dl 0
loc 38
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A CvssTestCase.test_cvssv2() 0 5 1
A CvssTestCase.test_cvssv3() 0 5 1
1
# Copyright (C) 2014-2021 Greenbone Networks GmbH
2
#
3
# SPDX-License-Identifier: AGPL-3.0-or-later
4
#
5
# This program is free software: you can redistribute it and/or modify
6
# it under the terms of the GNU Affero General Public License as
7
# published by the Free Software Foundation, either version 3 of the
8
# License, or (at your option) any later version.
9
#
10
# This program is distributed in the hope that it will be useful,
11
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
# GNU Affero General Public License for more details.
14
#
15
# You should have received a copy of the GNU Affero General Public License
16
# along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18
""" Test module for cvss scoring calculation
19
"""
20
21
import unittest
22
23
from ospd.cvss import CVSS
24
25
26
class CvssTestCase(unittest.TestCase):
27
    def test_cvssv2(self):
28
        vector = 'AV:A/AC:L/Au:S/C:P/I:P/A:P'
29
        cvss_base = CVSS.cvss_base_v2_value(vector)
30
31
        self.assertEqual(cvss_base, 5.2)
32
33
    def test_cvssv3(self):
34
        vector = 'CVSS:3.0/AV:N/AC:L/PR:H/UI:N/S:U/C:L/I:L/A:N'
35
        cvss_base = CVSS.cvss_base_v3_value(vector)
36
37
        self.assertEqual(cvss_base, 3.8)
38