in security_hub_correlation_cdk/lambdas/create_sh_finding/create_sh_finding.py [0:0]
def create_securityhub_finding (sh_payload):
findings = []
findings.append(
sh_payload
)
if len(findings) > 0:
logger.info('Creating custom Security Hub finding...')
try:
response = securityhub.batch_import_findings(
Findings=findings
)
logger.info("Successfully imported {} Security Hub findings".format(response['SuccessCount']))
except ClientError as error_handle:
if error_handle.response['Error']['Code'] == 'AccessDeniedException':
logger.warning('Check permissions to import Security Hub findings.')
else:
logger.error(error_handle.response['Error']['Code'])
if response['FailedCount'] > 0:
logger.info("Failed to import {} Security Hub findings".format(response['FailedCount']))
else:
logger.info('No DynamoDB Security Hub matches found...')