in enrichment_function/import_findings/app.py [0:0]
def enrich_finding(account_id, role):
#clear enrichment text
note_text = ""
#create enrichment text
account_details = AccountHelper.get_account_details(account_id=account_id, role_name=role)
tags_dict = {}
logger.debug("account_details: %s ", json.dumps(account_details))
note_text = note_text + "Account Name: " + account_details['Name']
note_text = note_text + " OU Name: " + account_details['OUName']
if account_details["tags"]:
tag_names = [tag["Key"] for tag in account_details["tags"]]
tag_values = [tag["Value"] for tag in account_details["tags"]]
tags_dict = dict(zip(tag_names,tag_values))
account_details["Tags"] = tags_dict
tags_string = ', '.join(key + "=" + value for key, value in tags_dict.items())
note_text = note_text + " Tags: " + tags_string
tags_dict["AccountName"] = account_details["Name"]
tags_dict["OU"] = account_details["OUName"]
tags_dict["findingEnriched"] = 'True'
if account_details["AlternateContact"]:
security_contact = " Security Contact Details: Name:{} | Title:{} | Email:{} | Phone {}".format(account_details["AlternateContact"]["Name"],account_details["AlternateContact"]["Title"],account_details["AlternateContact"]["EmailAddress"],account_details["AlternateContact"]["PhoneNumber"])
note_text = note_text + security_contact
tags_dict["securityContact"] = security_contact
logger.info("enrichment complete: %s" , note_text)
logger.info("enrichment: %s" , json.dumps(tags_dict))
return note_text,tags_dict