Minor variable and method refactoring to improve readability in scoutsuite code

This commit is contained in:
VakarisZ 2021-02-11 16:52:20 +02:00
parent 3cb2a63a9d
commit e96ee305fb
3 changed files with 9 additions and 12 deletions

View File

@ -16,7 +16,7 @@ def scan_cloud_security(cloud_type: CloudProviders):
results = run_scoutsuite(cloud_type.value)
if isinstance(results, dict) and 'error' in results and results['error']:
raise ScoutSuiteScanError(results['error'])
send_results(results)
send_scoutsuite_run_results(results)
except (Exception, ScoutSuiteScanError) as 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)
def send_results(results: BaseProvider):
ScoutSuiteTelem(results).send()
def send_scoutsuite_run_results(run_results: BaseProvider):
ScoutSuiteTelem(run_results).send()

View File

@ -6,18 +6,14 @@ from infection_monkey.telemetry.base_telem import BaseTelem
class ScoutSuiteTelem(BaseTelem):
def __init__(self, data: BaseProvider):
"""
Default ScoutSuite telemetry constructor
:param data: Data gathered via ScoutSuite
"""
def __init__(self, provider: BaseProvider):
super().__init__()
self.data = data
self.provider_data = provider
json_encoder = ScoutJsonEncoder
telem_category = TelemCategoryEnum.SCOUTSUITE
def get_data(self):
return {
'data': self.data
'data': self.provider_data
}

View File

@ -20,8 +20,9 @@ class MonkeyZTDetailsService:
'latest_events': {'$slice': ['$events', int(-1 * MAX_EVENT_FETCH_CNT / 2)]},
'event_count': {'$size': '$events'}}},
{'$unset': ['events']}]
details = list(MonkeyFindingDetails.objects.aggregate(*pipeline))[0]
if details:
detail_list = list(MonkeyFindingDetails.objects.aggregate(*pipeline))
if detail_list:
details = detail_list[0]
details['latest_events'] = MonkeyZTDetailsService._remove_redundant_events(details['event_count'],
details['latest_events'])
return details