From 9bf1c936cf486a6242465dc6b763120947ef6eb2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Vinot?= Date: Fri, 16 Dec 2016 15:22:16 +0100 Subject: [PATCH] Do not crash if the dat file is not available --- misp_modules/modules/expansion/geoip_country.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/misp_modules/modules/expansion/geoip_country.py b/misp_modules/modules/expansion/geoip_country.py index 047487d..31c1b6a 100644 --- a/misp_modules/modules/expansion/geoip_country.py +++ b/misp_modules/modules/expansion/geoip_country.py @@ -21,10 +21,14 @@ moduleinfo = {'version': '0.1', 'author': 'Andreas Muehlemann', 'description': 'Query a local copy of Maxminds Geolite database', 'module-type': ['expansion', 'hover']} -# get current db from http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz -config = configparser.ConfigParser() -config.read(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'geoip_country.cfg')) -gi = pygeoip.GeoIP(config.get('GEOIP', 'database')) +try: + # get current db from http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz + config = configparser.ConfigParser() + config.read(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'geoip_country.cfg')) + gi = pygeoip.GeoIP(config.get('GEOIP', 'database')) + enabled = True +except: + enabled = False def handler(q=False):