1010from restfly .utils import dict_clean , dict_flatten , trunc
1111
1212log = logging .getLogger ('sechub.finding' )
13- SEV_MAP = {0 : 0 , 1 : 3 , 2 : 5 , 3 : 7 , 4 : 10 }
13+ SEV_MAP = {0 : 'INFORMATIONAL' , 1 : 'LOW' , 2 : 'MEDIUM' , 3 : 'HIGH' , 4 : 'CRITICAL' }
1414STATE_MAP = {
1515 'OPEN' : 'ACTIVE' ,
1616 'NEW' : 'ACTIVE' ,
@@ -97,19 +97,6 @@ def generate(self, vuln: Dict) -> Dict:
9797 vuln = dict_flatten (vuln )
9898 self .check_required_params (vuln )
9999
100- # Get the base score of the finding. Amazon prefers that we use the
101- # CVSS base scores and fall back to our own severity rating only if
102- # necessary. We start with the CVSSv3 score, then fall back to v2,
103- # and lastly fall back to the severity_default_id.
104- # FIXME: I don't really like how this nested fallback looks, and I feel
105- # there has to be a cleaner way to implement.
106- base_score = vuln .get (
107- 'plugin.cvss3_base_score' ,
108- vuln .get (
109- 'plugin.cvss_base_score' , SEV_MAP [vuln .get ('severity_default_id' , 0 )]
110- ),
111- )
112-
113100 finding = {
114101 'SchemaVersion' : '2018-10-08' ,
115102 'FirstObservedAt' : vuln ['first_found' ],
@@ -128,11 +115,7 @@ def generate(self, vuln: Dict) -> Dict:
128115 'UpdatedAt' : self .start_date ,
129116 'Types' : ['Software and Configuration Checks/Vulnerabilities/CVE' ],
130117 'Severity' : {
131- 'Product' : base_score ,
132- # AWS' scoring system works differently than Tenable's. They
133- # use a
134- 'Normalized' : int (base_score * 4 ),
135- 'Label' : vuln ['plugin.risk_factor' ].upper (),
118+ 'Label' : SEV_MAP [vuln .get ('severity_default_id' , 0 )],
136119 },
137120 # Some plugin names run quite long, we will need to truncate to
138121 # the max string size that AWS supports.
@@ -177,7 +160,9 @@ def generate(self, vuln: Dict) -> Dict:
177160 'Remediation' : {
178161 'Recommendation' : {
179162 # The solution cannot exceed 1024 characters in length.
180- 'Text' : trunc (vuln ['plugin.solution' ], 512 ),
163+ 'Text' : trunc (vuln ['plugin.solution' ], 512 )
164+ if vuln .get ('plugin.solution' )
165+ else None ,
181166 'Url' : vuln .get ('plugin.see_also' )[0 ]
182167 if vuln .get ('plugin.see_also' )
183168 else None ,
0 commit comments