Skip to main content


Hello all,


how do I add enriched data to entity so that it will show in entity explorer


I was told I can use


flat_user_data = {"key1":"value1"}


entity.additional_properties.update(flat_user_data)


but it's throwing error how do I define entity?


Hi
@Farukh Shaik
can you please share the error you are receiving?



error is entity not defined



I'm guessing you got that snippet from
https://www.manula.com/manuals/siemplify/developers-hub/version.one/en/topic/my-first-action




If you note, "entity" in this case is being used as the iterator in the for loop


for entity in siemplify.target_entities:


siemplify.LOGGER.info(f"proccessing entity {entity.identifier}")


if (entity.entity_type == EntityTypes.HOSTNAME and not entity.is_internal) or entity.entity_type == EntityTypes.URL:


entity_to_scan = entity.identifier





scan_url = f"{url}&domainName={entity_to_scan}"





response = requests.get(scan_url)


response.raise_for_status()


register_details = response.json().get("WhoisRecord", {}).get("registrant", {})


if register_details:


entity.additional_properties.update(register_details)


successfull_entities.append(entity)



Which,
entity
is iterating over
siemplify.target_entities




So, I believe the answer to your question is you must have the following:




from SiemplifyAction import SiemplifyAction





siemplify = SiemplifyAction()





for entity in siemplify.target_entities:


flat_user_data = {"key1":"value1"}


entity.additional_properties.update(flat_user_data)



well, the line
entity.additional_properties.update(flat_user_data)
should be tabbed over to stay in the for loop.


Reply