File tree Expand file tree Collapse file tree 3 files changed +17
-4
lines changed Expand file tree Collapse file tree 3 files changed +17
-4
lines changed Original file line number Diff line number Diff line change @@ -113,4 +113,6 @@ wcwidth==0.2.5
113113websocket-client == 0.59.0
114114yarl == 1.7.2
115115zipp == 3.8.0
116- dateparser == 1.1.1
116+ dateparser == 1.1.1
117+ fetchcode == 0.1.0
118+ cvss == 2.4
Original file line number Diff line number Diff line change @@ -76,6 +76,7 @@ install_requires =
7676 defusedxml>=0.7.1
7777 Markdown>=3.3.0
7878 dateparser>=1.1.1
79+ cvss>=2.4
7980
8081 # networking
8182 GitPython>=3.1.17
Original file line number Diff line number Diff line change 2121# Visit https://github.com/nexB/vulnerablecode/ for support and download.
2222
2323import dataclasses
24+ from decimal import Decimal
25+
26+ from cvss import CVSS2
27+ from cvss import CVSS3
2428
2529"""
2630Vulnerability scoring systems define scales, values and approach to score a
3034
3135@dataclasses .dataclass (order = True )
3236class ScoringSystem :
33-
3437 # a short identifier for the scoring system.
3538 identifier : str
3639 # a name which represents the scoring system such as `RedHat bug severity`.
@@ -41,13 +44,20 @@ class ScoringSystem:
4144 # notes about that scoring system
4245 notes : str = ""
4346
44- def as_score (self , value ):
47+ def as_score (self , value ) -> Decimal :
4548 """
4649 Return a normalized numeric score for this scoring system given a raw
4750 value. For instance this can be used to convert a CVSS vector to a base
4851 score.
4952 """
50- raise NotImplementedError
53+ if self .identifier == "cvssv2_vector" :
54+ c = CVSS2 (value )
55+ return c .base_score
56+ elif self .identifier in ["cvssv3_vector" , "cvssv3.1_vector" ]:
57+ c = CVSS3 (value )
58+ return c .base_score
59+ else :
60+ raise NotImplementedError
5161
5262
5363CVSSV2 = ScoringSystem (
You can’t perform that action at this time.
0 commit comments