Merge pull request #161 from whoisroot/main

Fixing filters and redis GEOADD command
pull/167/head
Steve Clement 2021-12-31 11:44:34 +09:00 committed by GitHub
commit a196e4a2fa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 16 additions and 13 deletions

3
.gitignore vendored
View File

@ -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

View File

@ -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):

View File

@ -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

View File

@ -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",