Move to a common normalisation function
This commit is contained in:
@ -217,6 +217,7 @@ class NessusAPI(object):
|
||||
self.logger.debug('Changing case of fields')
|
||||
df['cve'] = df['cve'].str.upper()
|
||||
df['protocol'] = df['protocol'].str.lower()
|
||||
df['risk'] = df['risk'].str.lower()
|
||||
|
||||
# Copy asset to IP
|
||||
df['ip'] = df['asset']
|
||||
@ -225,27 +226,5 @@ class NessusAPI(object):
|
||||
self.logger.debug('Mapping risk to severity number')
|
||||
df['risk_number'] = df['risk'].str.lower().map(self.SEVERITY_MAPPING)
|
||||
|
||||
if self.profile == 'tenable':
|
||||
self.logger.debug('Combinging CVSS vectors for tenable')
|
||||
# Combine CVSS vectors
|
||||
df['cvss_vector'] = (
|
||||
df[['cvss_vector', 'cvss_temporal_vector']]
|
||||
.apply(lambda x: '{}/{}'.format(x[0], x[1]), axis=1)
|
||||
.str.rstrip('/nan')
|
||||
)
|
||||
df['cvss3_vector'] = (
|
||||
df[['cvss3_vector', 'cvss3_temporal_vector']]
|
||||
.apply(lambda x: '{}/{}'.format(x[0], x[1]), axis=1)
|
||||
.str.rstrip('/nan')
|
||||
)
|
||||
|
||||
df.drop(['cvss_temporal_vector', 'cvss3_temporal_vector'], axis=1, inplace=True)
|
||||
|
||||
# CVSS score = cvss3_temporal or cvss3_base or cvss_temporal or cvss_base
|
||||
df['cvss'] = df['cvss_base']
|
||||
df.loc[df['cvss_temporal'].notnull(), 'cvss'] = df['cvss_temporal']
|
||||
df['cvss3'] = df['cvss3_base']
|
||||
df.loc[df['cvss3_temporal'].notnull(), 'cvss3'] = df['cvss3_temporal']
|
||||
|
||||
df.fillna('', inplace=True)
|
||||
return df
|
@ -90,6 +90,8 @@ class qualysVulnScan:
|
||||
'title': 'plugin_name'
|
||||
}
|
||||
|
||||
SEVERITY_MAPPING = {0: 'none', 1: 'low', 2: 'medium', 3: 'high',4: 'critical'}
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
config=None,
|
||||
@ -184,23 +186,9 @@ class qualysVulnScan:
|
||||
.apply(lambda x: x[0])
|
||||
)
|
||||
|
||||
# Combine base and temporal
|
||||
df['cvss_vector'] = (
|
||||
df[['cvss_vector', 'cvss_temporal_vector']]
|
||||
.apply(lambda x: '{}/{}'.format(x[0], x[1]), axis=1)
|
||||
.str.rstrip('/nan')
|
||||
)
|
||||
|
||||
df.drop('cvss_temporal_vector', axis=1, inplace=True)
|
||||
|
||||
# Convert Qualys severity to standardised risk number
|
||||
df['risk_number'] = df['severity'].astype(int)-1
|
||||
|
||||
# CVSS score = cvss3_temporal or cvss3_base or cvss_temporal or cvss_base
|
||||
df['cvss'] = df['cvss_base']
|
||||
df.loc[df['cvss_temporal'].notnull(), 'cvss'] = df['cvss_temporal']
|
||||
df['cvss3'] = df['cvss3_base']
|
||||
df.loc[df['cvss3_temporal'].notnull(), 'cvss3'] = df['cvss3_temporal']
|
||||
df['risk'] = df['risk_number'].map(self.SEVERITY_MAPPING)
|
||||
|
||||
df.fillna('', inplace=True)
|
||||
|
||||
|
Reference in New Issue
Block a user