Permalink
Browse files

Remove ability for geoip class to guess db location

  • Loading branch information...
pwnbus committed Oct 30, 2018
1 parent 434788e commit e128bafebfcb2e2086ebdbd422948e6e0a6a95b7
Showing with 3 additions and 10 deletions.
  1. +1 −4 mozdef_util/mozdef_util/geo_ip.py
  2. +2 −6 tests/lib/test_geo_ip.py
@@ -1,11 +1,8 @@
import os
import geoip2.database
class GeoIP(object):
def __init__(self, db_location=None):
if db_location is None:
db_location = os.path.join(os.path.dirname(os.path.abspath(__file__)), "../../data/GeoLite2-City.mmdb")
def __init__(self, db_location):
try:
self.db = geoip2.database.Reader(db_location)
except IOError:
View
@@ -1,14 +1,10 @@
import os
import sys
from mozdef_util.geo_ip import GeoIP
class TestGeoIPLookup(object):
def setup(self):
self.geo_ip = GeoIP()
# Unfortunately since the db file is not present by default
# we verify the error
def test_without_db_file(self):
geo_dict = self.geo_ip.lookup_ip('129.21.1.40')
geo_ip = GeoIP("nonexistent_db")
geo_dict = geo_ip.lookup_ip('129.21.1.40')
assert geo_dict['error'] == 'No Geolite DB Found!'

0 comments on commit e128baf

Please sign in to comment.