chg: [trackers match] show objects date

ocr
terrtia 2024-03-22 11:37:35 +01:00
parent 406d72bb52
commit fa57171937
No known key found for this signature in database
GPG Key ID: 1E1B1F50D84613D0
7 changed files with 32 additions and 6 deletions

View File

@ -305,6 +305,8 @@ class Item(AbstractObject):
meta['investigations'] = self.get_investigations()
if 'link' in options:
meta['link'] = self.get_link(flask_context=True)
if 'last_full_date' in options:
meta['last_full_date'] = f"{meta['date'][0:4]}-{meta['date'][5:7]}-{meta['date'][8:10]}"
# meta['encoding'] = None
return meta

View File

@ -92,6 +92,10 @@ class Message(AbstractObject):
timestamp = self.get_timestamp()
return datetime.utcfromtimestamp(float(timestamp)).strftime('%Y%m%d')
def get_last_full_date(self):
timestamp = datetime.utcfromtimestamp(float(self.get_timestamp()))
return timestamp.strftime('%Y-%m-%d %H:%M:%S')
def get_timestamp(self):
dirs = self.id.split('/')
return dirs[1]
@ -255,6 +259,8 @@ class Message(AbstractObject):
meta['date'] = timestamp.strftime('%Y/%m/%d')
meta['hour'] = timestamp.strftime('%H:%M:%S')
meta['full_date'] = timestamp.isoformat(' ')
if 'last_full_date' in options:
meta['last_full_date'] = meta['full_date']
meta['source'] = self.get_source()
# optional meta fields

View File

@ -88,6 +88,8 @@ class AbstractDaterangeObject(AbstractObject, ABC):
meta_dict['nb_seen'] = self.get_nb_seen()
if 'sparkline' in options:
meta_dict['sparkline'] = self.get_sparkline()
if 'last_full_date'in options:
meta_dict['last_full_date'] = self.get_last_full_date()
return meta_dict
def set_first_seen(self, first_seen):

View File

@ -67,6 +67,9 @@ class AbstractObject(ABC):
def get_global_id(self):
return f'{self.get_type()}:{self.get_subtype(r_str=True)}:{self.get_id()}'
def get_last_full_date(self):
return None
def get_default_meta(self, tags=False, link=False):
dict_meta = {'id': self.get_id(),
'type': self.get_type(),

View File

@ -85,6 +85,11 @@ class AbstractSubtypeObject(AbstractObject, ABC):
else:
return int(nb)
def get_last_full_date(self):
last_seen = self.get_last_seen()
if last_seen:
return f'{last_seen[0:4]}-{last_seen[4:6]}-{last_seen[6:8]}'
def _get_meta(self, options=None):
if options is None:
options = set()

View File

@ -174,7 +174,7 @@ def show_tracker():
if date_from:
date_from, date_to = Date.sanitise_daterange(date_from, date_to)
objs = tracker.get_objs_by_daterange(date_from, date_to)
meta['objs'] = ail_objects.get_objects_meta(objs, flask_context=True)
meta['objs'] = ail_objects.get_objects_meta(objs, options={'last_full_date'}, flask_context=True)
else:
date_from = ''
date_to = ''

View File

@ -258,7 +258,7 @@
<th>Type</th>
<th></th>
<th>Id</th>
<th>Tags</th>
<th>Last Date</th>
<th></th>
</tr>
</thead>
@ -280,11 +280,19 @@
<a href="{{ object['link'] }}">
{{ object['id']}}
</a>
{% if object['tags'] %}
<div>
{% for tag in object['tags'] %}
<span class="badge badge-{{ bootstrap_label[loop.index0 % 5] }} pull-left">{{ tag }}</span>
{% endfor %}
</div>
{% endif %}
</td>
<td>
{% for tag in object['tags'] %}
<span class="badge badge-{{ bootstrap_label[loop.index0 % 5] }} pull-left">{{ tag }}</span>
{% endfor %}
{% if object['last_full_date'] %}
{{ object['last_full_date']}}
{% endif %}
</td>
<td class="text-right">
{# <a href="{{ url_for('investigations_b.unregister_investigation') }}?uuid={{ meta['uuid']}}&type={{ object['type'] }}&subtype={{ object['subtype']}}&id={{ object['id']}}">#}
@ -342,7 +350,7 @@
$('#myTable_').DataTable({
"aLengthMenu": [[5, 10, 15, -1], [5, 10, 15, "All"]],
"iDisplayLength": 10,
"order": [[0, "asc"]]
"order": [[3, "desc"]]
});
sparkline("sparkline", {{ meta['sparkline'] }}, {});