mirror of https://github.com/MISP/misp-modules
updated
parent
7c42950e9b
commit
6ac1ea946e
|
@ -13,7 +13,6 @@ moduleinfo = {
|
||||||
'module-type': ['expansion', 'hover']
|
'module-type': ['expansion', 'hover']
|
||||||
}
|
}
|
||||||
moduleconfig = ['apiKey']
|
moduleconfig = ['apiKey']
|
||||||
misperrors = {'error': 'Error'}
|
|
||||||
|
|
||||||
|
|
||||||
def handler(q=False):
|
def handler(q=False):
|
||||||
|
@ -22,32 +21,25 @@ def handler(q=False):
|
||||||
return False
|
return False
|
||||||
request = json.loads(q)
|
request = json.loads(q)
|
||||||
if not request.get('config'):
|
if not request.get('config'):
|
||||||
misperrors['error'] = 'IpGeolocation Configuration is missing'
|
return {'error' : 'IpGeolocation Configuration is missing'}
|
||||||
return misperrors
|
|
||||||
if not request['config'].get('apiKey'):
|
if not request['config'].get('apiKey'):
|
||||||
misperrors['error'] = 'IpGeolocation apiKey is missing'
|
return {'error' : 'IpGeolocation apiKey is missing'}
|
||||||
return misperrors
|
|
||||||
|
|
||||||
if request['attribute']['type'] not in mispattributes['input']:
|
if request['attribute']['type'] not in mispattributes['input']:
|
||||||
return {'error': 'Unsupported attribute type.'}
|
return {'error': 'Unsupported attribute type.'}
|
||||||
|
|
||||||
try:
|
ip = request['attribute']['value']
|
||||||
ip = request['attribute']['value']
|
apiKey = request['config']['apiKey']
|
||||||
except Exception:
|
response = handle_ip(apiKey, ip)
|
||||||
return {'error': 'Error Getting IP' + request}
|
return {'error': 'Going to the handleIP method' + response}
|
||||||
try:
|
|
||||||
apiKey = request['config']['apiKey']
|
|
||||||
except Exception:
|
|
||||||
return {'error': 'Error Getting apiKey' + request}
|
|
||||||
return handle_ip(apiKey, ip, misperrors)
|
|
||||||
|
|
||||||
def handle_ip(apiKey, ip, misperrors):
|
|
||||||
|
def handle_ip(apiKey, ip):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
results = query_ipgeolocation(apiKey, ip)
|
results = query_ipgeolocation(apiKey, ip)
|
||||||
except Exception:
|
except Exception:
|
||||||
misperrors['error'] = "Error while Querying IP Address"
|
return {'error' : 'Error during querying IPGeolocation API.'}
|
||||||
return []
|
|
||||||
|
|
||||||
|
|
||||||
# Check if the IP address is not reserved for special use
|
# Check if the IP address is not reserved for special use
|
||||||
|
|
Loading…
Reference in New Issue