* Exceptions handling for sending findings

This commit is contained in:
maor.rayzin 2018-11-27 10:28:41 +02:00
parent f506eb3dd1
commit 90554f63cb
1 changed files with 9 additions and 5 deletions

View File

@ -77,12 +77,16 @@ class AWSExporter(Exporter):
securityhub = boto3.client('securityhub', securityhub = boto3.client('securityhub',
aws_access_key_id=creds_dict.get('aws_access_key_id', ''), aws_access_key_id=creds_dict.get('aws_access_key_id', ''),
aws_secret_access_key=creds_dict.get('aws_secret_access_key', '')) aws_secret_access_key=creds_dict.get('aws_secret_access_key', ''))
try:
import_response = securityhub.batch_import_findings(Findings=findings_list) import_response = securityhub.batch_import_findings(Findings=findings_list)
print import_response print import_response
if import_response['ResponseMetadata']['HTTPStatusCode'] == 200: if import_response['ResponseMetadata']['HTTPStatusCode'] == 200:
return True return True
else: else:
return False return False
except Exception as e:
logger.error('AWS security hub findings failed to send.')
return False
@staticmethod @staticmethod
def _handle_tunnel_issue(issue): def _handle_tunnel_issue(issue):