From 4ba86d4fa3c390d52a68d29be3df43df33ec21fc Mon Sep 17 00:00:00 2001 From: Hannah Ward Date: Wed, 17 Aug 2016 09:51:16 +0100 Subject: [PATCH] CountryCode JSON now is only grabbed once per server run --- misp_modules/modules/expansion/countrycode.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/misp_modules/modules/expansion/countrycode.py b/misp_modules/modules/expansion/countrycode.py index 039da17..af58fc6 100755 --- a/misp_modules/modules/expansion/countrycode.py +++ b/misp_modules/modules/expansion/countrycode.py @@ -20,7 +20,10 @@ common_tlds = {"com":"Commercial (Worldwide)", "gov":"Government (USA)" } +codes = requests.get("http://www.geognos.com/api/en/countries/info/all.json").json() + def handler(q=False): + global codes if q is False: return False request = json.loads(q) @@ -34,8 +37,6 @@ def handler(q=False): val = common_tlds[ext] else: # Retrieve a json full of country info - codes = requests.get("http://www.geognos.com/api/en/countries/info/all.json").json() - if not codes["StatusMsg"] == "OK": val = "Unknown" else: