chg: [dashboard] filter submission tags

This commit is contained in:
terrtia 2024-12-09 10:13:26 +01:00
parent 9dde795c12
commit feabe9f5df
No known key found for this signature in database
GPG key ID: 1E1B1F50D84613D0
2 changed files with 8 additions and 5 deletions

View file

@ -28,6 +28,8 @@ r_tags = config_loader.get_db_conn("Kvrocks_Tags")
r_cache = config_loader.get_redis_conn("Redis_Cache")
config_loader = None
TAGS_TO_EXCLUDE_FROM_DASHBOARD = {'infoleak:submission="crawler"', 'infoleak:submission="manual"'}
#### CORE FUNCTIONS ####
# # # # UNSAFE TAGS # # # #
@ -712,6 +714,7 @@ def add_object_tag(tag, obj_type, obj_id, subtype=''):
# STATS
r_tags.hincrby(f'daily_tags:{datetime.date.today().strftime("%Y%m%d")}', tag, 1)
mess = f'{int(time.time())}:{obj_type}:{subtype}:{obj_id}'
if tag not in TAGS_TO_EXCLUDE_FROM_DASHBOARD:
r_tags.lpush('dashboard:tags', mess)
r_tags.ltrim('dashboard:tags', 0, 19)

View file

@ -5,7 +5,7 @@
The Tags Module
================================
This module add tags to an item.
This module add tags to an object.
"""
@ -36,11 +36,11 @@ class Tags(AbstractModule):
self.logger.info(f'Module {self.module_name} initialized')
def compute(self, message):
item = self.obj
obj = self.obj
tag = message
# Create a new tag
item.add_tag(tag)
obj.add_tag(tag)
print(f'{self.obj.get_global_id()}: Tagged {tag}')
# Forward message to channel