From 6248dd7bbe853a8bfaf4366bc01e92f8b1d99764 Mon Sep 17 00:00:00 2001 From: terrtia Date: Wed, 29 Jan 2025 15:14:44 +0100 Subject: [PATCH] chg: [show item] show file-name and message content --- bin/lib/objects/Items.py | 12 ++++++++ var/www/blueprints/objects_item.py | 13 +++++++-- var/www/templates/objects/item/show_item.html | 29 ++++++++++++++++--- 3 files changed, 48 insertions(+), 6 deletions(-) diff --git a/bin/lib/objects/Items.py b/bin/lib/objects/Items.py index d50a6155..510104d9 100755 --- a/bin/lib/objects/Items.py +++ b/bin/lib/objects/Items.py @@ -149,6 +149,16 @@ class Item(AbstractObject): r_object.sadd(f'child:item::{self.id}', child_id) r_object.hset(f'meta:item::{child_id}', 'parent', self.id) + def get_file_name(self): + filename = self.get_correlation('file-name').get('file-name') + if filename: + return filename.pop()[1:] + + def get_message(self): + filename = self.get_correlation('message').get('message') + if filename: + return filename.pop()[1:] + #################################################################################### #################################################################################### @@ -271,6 +281,8 @@ class Item(AbstractObject): meta['crawler'] = self.get_meta_crawler(tags=tags) if 'duplicates' in options: meta['duplicates'] = self.get_duplicates() + if 'file_name' in options: + meta['file_name'] = self.get_file_name() if 'lines' in options: content = meta.get('content') meta['lines'] = self.get_meta_lines(content=content) diff --git a/var/www/blueprints/objects_item.py b/var/www/blueprints/objects_item.py index ec0c38ea..e867bbef 100644 --- a/var/www/blueprints/objects_item.py +++ b/var/www/blueprints/objects_item.py @@ -20,6 +20,7 @@ sys.path.append(os.environ['AIL_BIN']) # Import Project packages ################################## from lib import ConfigLoader +from lib import chats_viewer from lib import item_basic from lib.objects.Items import Item from lib.objects.Screenshots import Screenshot @@ -68,7 +69,15 @@ def showItem(): # # TODO: support post abort(404) item = Item(item_id) - meta = item.get_meta(options={'content', 'crawler', 'duplicates', 'investigations', 'lines', 'size'}) + meta = item.get_meta(options={'content', 'crawler', 'duplicates', 'file_name', 'investigations', 'lines', 'size'}) + if meta['file_name']: + message = chats_viewer.api_get_message(item.get_message()) + if message[1] == 200: + message = message[0] + else: + message = None + else: + message = None meta['name'] = meta['id'].replace('/', ' / ') meta['father'] = item_basic.get_item_parent(item_id) @@ -95,7 +104,7 @@ def showItem(): # # TODO: support post return render_template("show_item.html", bootstrap_label=bootstrap_label, modal_add_tags=Tag.get_modal_add_tags(meta['id'], object_type='item'), is_hive_connected=False, - meta=meta, + meta=meta, message=message, extracted=extracted, extracted_matches=extracted_matches) # kvrocks data diff --git a/var/www/templates/objects/item/show_item.html b/var/www/templates/objects/item/show_item.html index 02ed8f5f..959d9696 100644 --- a/var/www/templates/objects/item/show_item.html +++ b/var/www/templates/objects/item/show_item.html @@ -499,9 +499,14 @@ {% endif %} - {% for row in extracted_matches[match]['matches'] %} - {{ row[2] }}
- {% endfor %} + +
+ {% for row in extracted_matches[match]['matches'] %} + {{ row[2] }}
+ {% endfor %} +
{% endfor %} @@ -515,7 +520,23 @@ {% endif %} - + + + + + +{% if meta['file_name'] %} +
+
+ {% with message=message %} + {% include 'chats_explorer/block_message.html' %} + {% endwith %} +
+
+{% endif %} + + +