Skip to content

Commit

Permalink
chg: [trackers match] show objects date
Browse files Browse the repository at this point in the history
  • Loading branch information
Terrtia committed Mar 22, 2024
1 parent 406d72b commit fa57171
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 6 deletions.
2 changes: 2 additions & 0 deletions bin/lib/objects/Items.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,8 @@ def get_meta(self, options=None):
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
Expand Down
6 changes: 6 additions & 0 deletions bin/lib/objects/Messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@ def get_date(self):
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]
Expand Down Expand Up @@ -255,6 +259,8 @@ def get_meta(self, options=None, timestamp=None, translation_target=''):
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
Expand Down
2 changes: 2 additions & 0 deletions bin/lib/objects/abstract_daterange_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ def _get_meta(self, options=[]):
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):
Expand Down
3 changes: 3 additions & 0 deletions bin/lib/objects/abstract_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ def get_subtype(self, r_str=False):
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(),
Expand Down
5 changes: 5 additions & 0 deletions bin/lib/objects/abstract_subtype_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,11 @@ def get_nb_seen_by_date(self, date_day):
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()
Expand Down
2 changes: 1 addition & 1 deletion var/www/blueprints/hunters.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = ''
Expand Down
18 changes: 13 additions & 5 deletions var/www/templates/hunter/tracker_show.html
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ <h5 class="mb-0">Yara Rule:</h5>
<th>Type</th>
<th></th>
<th>Id</th>
<th>Tags</th>
<th>Last Date</th>
<th></th>
</tr>
</thead>
Expand All @@ -280,11 +280,19 @@ <h5 class="mb-0">Yara Rule:</h5>
<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']}}">#}
Expand Down Expand Up @@ -342,7 +350,7 @@ <h5 class="mb-0">Yara Rule:</h5>
$('#myTable_').DataTable({
"aLengthMenu": [[5, 10, 15, -1], [5, 10, 15, "All"]],
"iDisplayLength": 10,
"order": [[0, "asc"]]
"order": [[3, "desc"]]
});

sparkline("sparkline", {{ meta['sparkline'] }}, {});
Expand Down

0 comments on commit fa57171

Please sign in to comment.