Minor variable and method refactoring to improve readability in scoutsuite code
This commit is contained in:
parent
3cb2a63a9d
commit
e96ee305fb
|
@ -16,7 +16,7 @@ def scan_cloud_security(cloud_type: CloudProviders):
|
||||||
results = run_scoutsuite(cloud_type.value)
|
results = run_scoutsuite(cloud_type.value)
|
||||||
if isinstance(results, dict) and 'error' in results and results['error']:
|
if isinstance(results, dict) and 'error' in results and results['error']:
|
||||||
raise ScoutSuiteScanError(results['error'])
|
raise ScoutSuiteScanError(results['error'])
|
||||||
send_results(results)
|
send_scoutsuite_run_results(results)
|
||||||
except (Exception, ScoutSuiteScanError) as e:
|
except (Exception, ScoutSuiteScanError) as e:
|
||||||
logger.error(f"ScoutSuite didn't scan {cloud_type.value} security because: {e}")
|
logger.error(f"ScoutSuite didn't scan {cloud_type.value} security because: {e}")
|
||||||
|
|
||||||
|
@ -28,5 +28,5 @@ def run_scoutsuite(cloud_type: str) -> Union[BaseProvider, dict]:
|
||||||
aws_session_token=WormConfiguration.aws_session_token)
|
aws_session_token=WormConfiguration.aws_session_token)
|
||||||
|
|
||||||
|
|
||||||
def send_results(results: BaseProvider):
|
def send_scoutsuite_run_results(run_results: BaseProvider):
|
||||||
ScoutSuiteTelem(results).send()
|
ScoutSuiteTelem(run_results).send()
|
||||||
|
|
|
@ -6,18 +6,14 @@ from infection_monkey.telemetry.base_telem import BaseTelem
|
||||||
|
|
||||||
class ScoutSuiteTelem(BaseTelem):
|
class ScoutSuiteTelem(BaseTelem):
|
||||||
|
|
||||||
def __init__(self, data: BaseProvider):
|
def __init__(self, provider: BaseProvider):
|
||||||
"""
|
|
||||||
Default ScoutSuite telemetry constructor
|
|
||||||
:param data: Data gathered via ScoutSuite
|
|
||||||
"""
|
|
||||||
super().__init__()
|
super().__init__()
|
||||||
self.data = data
|
self.provider_data = provider
|
||||||
|
|
||||||
json_encoder = ScoutJsonEncoder
|
json_encoder = ScoutJsonEncoder
|
||||||
telem_category = TelemCategoryEnum.SCOUTSUITE
|
telem_category = TelemCategoryEnum.SCOUTSUITE
|
||||||
|
|
||||||
def get_data(self):
|
def get_data(self):
|
||||||
return {
|
return {
|
||||||
'data': self.data
|
'data': self.provider_data
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,8 +20,9 @@ class MonkeyZTDetailsService:
|
||||||
'latest_events': {'$slice': ['$events', int(-1 * MAX_EVENT_FETCH_CNT / 2)]},
|
'latest_events': {'$slice': ['$events', int(-1 * MAX_EVENT_FETCH_CNT / 2)]},
|
||||||
'event_count': {'$size': '$events'}}},
|
'event_count': {'$size': '$events'}}},
|
||||||
{'$unset': ['events']}]
|
{'$unset': ['events']}]
|
||||||
details = list(MonkeyFindingDetails.objects.aggregate(*pipeline))[0]
|
detail_list = list(MonkeyFindingDetails.objects.aggregate(*pipeline))
|
||||||
if details:
|
if detail_list:
|
||||||
|
details = detail_list[0]
|
||||||
details['latest_events'] = MonkeyZTDetailsService._remove_redundant_events(details['event_count'],
|
details['latest_events'] = MonkeyZTDetailsService._remove_redundant_events(details['event_count'],
|
||||||
details['latest_events'])
|
details['latest_events'])
|
||||||
return details
|
return details
|
||||||
|
|
Loading…
Reference in New Issue