pull/618/head
Usama015 2023-06-19 16:11:58 +05:00
parent a15d06e94f
commit 7c42950e9b
1 changed files with 6 additions and 4 deletions

View File

@ -47,7 +47,7 @@ def handle_ip(apiKey, ip, misperrors):
results = query_ipgeolocation(apiKey, ip) results = query_ipgeolocation(apiKey, ip)
except Exception: except Exception:
misperrors['error'] = "Error while Querying IP Address" misperrors['error'] = "Error while Querying IP Address"
return [], False return []
# Check if the IP address is not reserved for special use # Check if the IP address is not reserved for special use
@ -65,9 +65,11 @@ def handle_ip(apiKey, ip, misperrors):
# Parse the geolocation information related to the IP address # Parse the geolocation information related to the IP address
ipObject = MISPObject('ip-api-address') ipObject = MISPObject('ip-api-address')
mapping = get_mapping() mapping = get_mapping()
for field, relation in mapping.items(): try:
ipObject.add_attribute(relation, results[field]) for field, relation in mapping.items():
ipObject.add_attribute(relation, results[field])
except Exception:
return {'error': 'Error while Adding attributes'}
misp_event.add_object(ipObject) misp_event.add_object(ipObject)
# Return the results in MISP format # Return the results in MISP format