Skip to content

Commit

Permalink
#39 Manage exception for a domain that does not exist : geo query ret…
Browse files Browse the repository at this point in the history
…urns {} and the program raises an error
  • Loading branch information
jeromeleonard committed Dec 10, 2016
1 parent a8e9ad8 commit 107cae2
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions analyzers/OTXQuery/otxquery.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -97,19 +97,25 @@ def OTX_Query_Domain(data):
except:
error('API Error! Please verify data type is correct.')

json.dump({
result = {
'pulse_count': IP_['general']['pulse_info']['count'],
'pulses': IP_['general']['pulse_info']['pulses'],
'whois': IP_['general']['whois'],
'continent_code': IP_['geo']['continent_code'],
'country_code': IP_['geo']['country_code'],
'country_name': IP_['geo']['country_name'],
'city': IP_['geo']['city'],
'asn': IP_['geo']['asn'],
'malware_samples': IP_['malware']['result'],
'url_list': IP_['url_list']['url_list'],
'passive_dns': IP_['passive_dns']['passive_dns']
}, sys.stdout, ensure_ascii=False)
'passive_dns': IP_['passive_dns']['passive_dns']}

try:
result.update({
'continent_code': IP_['geo']['continent_code'],
'country_code': IP_['geo']['country_code'],
'country_name': IP_['geo']['country_name'],
'city': IP_['geo']['city'],
'asn': IP_['geo']['asn']})
except Exception:
pass

json.dump(result,sys.stdout, ensure_ascii=False)


def OTX_Query_File(data):
Expand All @@ -125,7 +131,7 @@ def OTX_Query_File(data):
except:
error('API Error! Please verify data type is correct.')


if IP_['analysis']['analysis']: # file has been analyzed before
json.dump({
'pulse_count': IP_['general']['pulse_info']['count'],
Expand Down Expand Up @@ -174,7 +180,7 @@ def OTX_Query_URL(data):
# run only if TLP condition is met
if tlp > max_tlp:
error('Error with TLP value ; see max_tlp in config or tlp value in input data')

# setup proxy
if http_proxy != None:
os.environ['http_proxy'] = http_proxy
Expand Down

0 comments on commit 107cae2

Please sign in to comment.