File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -78,6 +78,7 @@ install_requires =
7878 defusedxml>=0.7.1
7979 Markdown>=3.3.0
8080 dateparser>=1.1.1
81+ cvss>=2.4
8182
8283 # networking
8384 GitPython>=3.1.17
Original file line number Diff line number Diff line change 88#
99
1010import dataclasses
11+ from decimal import Decimal
12+
13+ from cvss import CVSS2
14+ from cvss import CVSS3
1115
1216"""
1317Vulnerability scoring systems define scales, values and approach to score a
1721
1822@dataclasses .dataclass (order = True )
1923class ScoringSystem :
20-
2124 # a short identifier for the scoring system.
2225 identifier : str
2326 # a name which represents the scoring system such as `RedHat bug severity`.
@@ -28,13 +31,20 @@ class ScoringSystem:
2831 # notes about that scoring system
2932 notes : str = ""
3033
31- def as_score (self , value ):
34+ def as_score (self , value ) -> Decimal :
3235 """
3336 Return a normalized numeric score for this scoring system given a raw
3437 value. For instance this can be used to convert a CVSS vector to a base
3538 score.
3639 """
37- raise NotImplementedError
40+ if self .identifier == "cvssv2_vector" :
41+ c = CVSS2 (value )
42+ return c .base_score
43+ elif self .identifier in ["cvssv3_vector" , "cvssv3.1_vector" ]:
44+ c = CVSS3 (value )
45+ return c .base_score
46+ else :
47+ raise NotImplementedError
3848
3949
4050CVSSV2 = ScoringSystem (
You can’t perform that action at this time.
0 commit comments