From 1153d5cd173442127f219cfa1f19bbced5309245 Mon Sep 17 00:00:00 2001 From: Alexandre Dulaunoy Date: Fri, 29 May 2020 11:44:20 +0200 Subject: [PATCH] chg: [tai-server] proper handling for non-existing threat-actor in queried country --- bin/tai-server.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/bin/tai-server.py b/bin/tai-server.py index c11d338..189585a 100644 --- a/bin/tai-server.py +++ b/bin/tai-server.py @@ -32,13 +32,17 @@ class Query(tornado.web.RequestHandler): for uuid in tai_names[query['name'].lower()]: result.append(tai_full[uuid]) if 'country' in query: - ta = tai_country[query['country'].lower()] - result = [] - for uuid in tai_country[query['country'].lower()]: - result.append(tai_full[uuid]) + if query['country'].lower() in tai_country: + ta = tai_country[query['country'].lower()] + result = [] + for uuid in tai_country[query['country'].lower()]: + result.append(tai_full[uuid]) + else: + result = {'error': 'Not existing country in the MISP galaxy threat-actor'} print("Query {} from {}".format(query, user_agent)) return self.write("{}".format(json.dumps(result))) + class Get(tornado.web.RequestHandler): def prepare(self):