From 100948b4df6b4db5d1c8cc3d4dad87049b8b7696 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucas=20Magalh=C3=A3es?= Date: Tue, 14 Dec 2021 23:46:18 +0000 Subject: [PATCH 1/4] Fix redis GEOADD Redis python interface only accepts two arguments, the keyname to store in redis and a value-list with the coordinates and content to which the coordinates refer, in groups of three. --- helpers/geo_helper.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/helpers/geo_helper.py b/helpers/geo_helper.py index 5fe678b..4900732 100644 --- a/helpers/geo_helper.py +++ b/helpers/geo_helper.py @@ -208,11 +208,15 @@ class Geo_helper: today_str = util.getDateStrFormat(now) keyname = "{}:{}".format(keyCateg, today_str) try: - self.serv_redis_db.geoadd(keyname, lon, lat, content) + self.serv_redis_db.geoadd(keyname, [lon, lat, content]) except redis.exceptions.ResponseError as error: print(error) print("Please fix the above, and make sure you use a redis version that supports the GEOADD command.") print("To test for support: echo \"help GEOADD\"| redis-cli") + except redis.exceptions.DataError as error: + print(error) + print("Please fix the above, and make sure you use a redis version that supports the GEOADD command.") + print("To test for support: echo \"help GEOADD\"| redis-cli") self.logger.debug('Added to redis: keyname={}, lon={}, lat={}, content={}'.format(keyname, lon, lat, content)) def push_to_redis_zset(self, keyCateg, toAdd, endSubkey="", count=1): From e852c477ade065ef414a143661400b2863d761d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucas=20Magalh=C3=A3es?= Date: Tue, 21 Dec 2021 00:20:30 +0000 Subject: [PATCH 2/4] Fix filters To compare for "not equal" values you should invert the match, not directly compare with the string prepended with "!". --- server.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server.py b/server.py index f4ba7c3..6b45af2 100755 --- a/server.py +++ b/server.py @@ -304,7 +304,7 @@ class LogItem(): def pass_filter(self): for filter, filterValue in self.filters.items(): jsonValue = util.getFields(self.feed, filter) - if jsonValue is None or jsonValue != filterValue: + if jsonValue is None or ("!" not in filterValue and jsonValue != filterValue) or ("!" in filterValue and jsonValue == filterValue.strip("!")): return False return True From a722be21be096a2b72a26b0ac9a5b9cbcaf04465 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucas=20Magalh=C3=A3es?= Date: Tue, 21 Dec 2021 04:16:59 +0000 Subject: [PATCH 3/4] Ignore redis database dump --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index 25954a6..8f63e9a 100644 --- a/.gitignore +++ b/.gitignore @@ -12,6 +12,9 @@ config/config.cfg # ignore GeoLite DB data/GeoLite2-City* +# ignore redis database dump +data/dump.rdb + # Created by https://www.gitignore.io/api/python # Edit at https://www.gitignore.io/?templates=python From 7f3a05ffc0d934ce0e23849f47634f6f9aefeed6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucas=20Magalh=C3=A3es?= Date: Wed, 22 Dec 2021 13:45:03 -0300 Subject: [PATCH 4/4] Fix filters - part 2 Org and Orgc are objects on events, and the match is to be applied to id, name or uuid for easier usage of the filters. Also, I could not find occurences of Org or Orgc outside of Event, so I removed them from the list too. --- static/js/index/index.js | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/static/js/index/index.js b/static/js/index/index.js index 1a4f005..ca63f63 100644 --- a/static/js/index/index.js +++ b/static/js/index/index.js @@ -748,8 +748,12 @@ $(document).ready(function() { 'Attribute.type', 'Attribute.uuid', 'Attribute.value', - 'Event.Org', - 'Event.Orgc', + 'Event.Org.id', + 'Event.Org.name', + 'Event.Org.uuid', + 'Event.Orgc.id', + 'Event.Orgc.name', + 'Event.Orgc.uuid', 'Event.analysis', 'Event.attribute_count', 'Event.date', @@ -760,8 +764,6 @@ $(document).ready(function() { 'Event.id', 'Event.info', 'Event.locked', - 'Event.org_id', - 'Event.orgc_id', 'Event.proposal_email_lock', 'Event.publish_timestamp', 'Event.published', @@ -769,13 +771,7 @@ $(document).ready(function() { 'Event.threat_level_id', 'Event.Tag.name', 'Event.timestamp', - 'Event.uuid', - 'Org.id', - 'Org.name', - 'Org.uuid', - 'Orgc.id', - 'Orgc.name', - 'Orgc.uuid' + 'Event.uuid' ].forEach(function(field) { var tempFilter = { "input": "text",