Skip to content

Commit 0291727

Browse files
committed
Updated schema to pass the severity using the updated AWS schema #47
1 parent eb63f87 commit 0291727

File tree

2 files changed

+6
-21
lines changed

2 files changed

+6
-21
lines changed

tenable_aws_sechub/finding.py

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from restfly.utils import dict_clean, dict_flatten, trunc
1111

1212
log = 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'}
1414
STATE_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,

tenable_aws_sechub/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
version = '2.1.1'
1+
version = '2.2.0'

0 commit comments

Comments
 (0)