diff --git a/bin/lib/Tracker.py b/bin/lib/Tracker.py index e35ead1a..f622130a 100755 --- a/bin/lib/Tracker.py +++ b/bin/lib/Tracker.py @@ -333,6 +333,8 @@ class Tracker: 'last_seen': self.get_last_seen()} if 'org' in options: meta['org'] = self.get_org() + if 'org_name' in options: + meta['org_name'] = ail_orgs.Organisation(self.get_org()).get_name() if 'user' in options: meta['user'] = self.get_user() if 'level' in options: @@ -725,21 +727,21 @@ def get_user_trackers_meta(user_id, tracker_type=None): metas = [] for tracker_uuid in get_user_trackers(user_id, tracker_type=tracker_type): tracker = Tracker(tracker_uuid) - metas.append(tracker.get_meta(options={'description', 'mails', 'sparkline', 'tags'})) + metas.append(tracker.get_meta(options={'description', 'mails', 'org', 'org_name', 'sparkline', 'tags'})) return metas def get_global_trackers_meta(tracker_type=None): metas = [] for tracker_uuid in get_global_trackers(tracker_type=tracker_type): tracker = Tracker(tracker_uuid) - metas.append(tracker.get_meta(options={'description', 'mails', 'sparkline', 'tags'})) + metas.append(tracker.get_meta(options={'description', 'mails', 'org', 'org_name', 'sparkline', 'tags'})) return metas def get_org_trackers_meta(user_org, tracker_type=None): metas = [] for tracker_uuid in get_org_trackers(user_org, tracker_type=tracker_type): tracker = Tracker(tracker_uuid) - metas.append(tracker.get_meta(options={'description', 'mails', 'sparkline', 'tags'})) + metas.append(tracker.get_meta(options={'description', 'mails', 'org', 'org_name', 'sparkline', 'tags'})) return metas def get_users_trackers_meta(): @@ -1556,6 +1558,10 @@ class RetroHunt: meta['nb_match'] = self.get_nb_match() if 'nb_objs' in options: meta['nb_objs'] = self.get_nb_objs() + if 'org' in options: + meta['org'] = self.get_org() + if 'org_name' in options: + meta['org_name'] = ail_orgs.Organisation(self.get_org()).get_name() if 'progress' in options: meta['progress'] = self.get_progress() if 'filters' in options: @@ -1758,6 +1764,14 @@ def get_retro_hunts_global(): def get_retro_hunts_org(org_uuid): return ail_orgs.get_org_objs_by_type(org_uuid, 'retro_hunt') +def get_retro_hunts_orgs(): + retros = [] + for retro_uuid in get_all_retro_hunt_tasks(): + retro = RetroHunt(retro_uuid) + if retro.get_level() == 2: + retros.append(retro_uuid) + return retros + def get_retro_hunt_pending_tasks(): return r_tracker.smembers('retro_hunts:pending') @@ -1785,7 +1799,7 @@ def get_retro_hunt_metas(trackers_uuid): tasks = [] for task_uuid in trackers_uuid: retro_hunt = RetroHunt(task_uuid) - tasks.append(retro_hunt.get_meta(options={'date', 'progress', 'nb_match', 'tags'})) + tasks.append(retro_hunt.get_meta(options={'date', 'progress', 'org', 'org_name', 'nb_match', 'tags'})) return tasks ## Objects ## diff --git a/var/www/blueprints/hunters.py b/var/www/blueprints/hunters.py index 9ed9c8e3..94c192a9 100644 --- a/var/www/blueprints/hunters.py +++ b/var/www/blueprints/hunters.py @@ -167,7 +167,7 @@ def show_tracker(): date_to = date_to.replace('-', '') tracker = Tracker.Tracker(tracker_uuid) - meta = tracker.get_meta(options={'description', 'level', 'mails', 'filters', 'sparkline', 'tags', + meta = tracker.get_meta(options={'description', 'level', 'mails', 'org', 'org_name', 'filters', 'sparkline', 'tags', 'user', 'webhooks', 'nb_objs'}) if meta['type'] == 'yara': @@ -486,6 +486,13 @@ def retro_hunt_all_tasks(): retro_hunts_org = Tracker.get_retro_hunt_metas(Tracker.get_retro_hunts_org(user_org)) return render_template("retro_hunt_tasks.html", retro_hunts_global=retro_hunts_global, retro_hunts_org=retro_hunts_org, bootstrap_label=bootstrap_label) +@hunters.route('/retro_hunt/tasks/admin', methods=['GET']) +@login_required +@login_admin +def retro_hunt_all_tasks_admin(): + retro_hunts_org = Tracker.get_retro_hunt_metas(Tracker.get_retro_hunts_orgs()) + return render_template("retro_hunt_tasks.html", retro_hunts_global=[], retro_hunts_org=retro_hunts_org, bootstrap_label=bootstrap_label) + @hunters.route('/retro_hunt/task/show', methods=['GET']) @login_required @login_read_only @@ -512,7 +519,7 @@ def retro_hunt_show_task(): if res: return res - dict_task = retro_hunt.get_meta(options={'creator', 'date', 'description', 'level', 'progress', 'filters', 'nb_objs', 'tags'}) + dict_task = retro_hunt.get_meta(options={'creator', 'date', 'description', 'level', 'org', 'org_name', 'progress', 'filters', 'nb_objs', 'tags'}) rule_content = Tracker.get_yara_rule_content(dict_task['rule']) dict_task['filters'] = json.dumps(dict_task['filters'], indent=4) diff --git a/var/www/templates/hunter/retro_hunt_tasks.html b/var/www/templates/hunter/retro_hunt_tasks.html index b722b1b6..cc731c17 100644 --- a/var/www/templates/hunter/retro_hunt_tasks.html +++ b/var/www/templates/hunter/retro_hunt_tasks.html @@ -41,6 +41,7 @@ Name + Org Date Nb Matches @@ -64,6 +65,9 @@ {% endfor %} + + {{ dict_task['org_name'] }}
{{ dict_task['org'] }} + {{ dict_task['date'][0:4]}}/{{ dict_task['date'][4:6]}}/{{ dict_task['date'][6:8]}}

{{dict_task['nb_match']}}

@@ -108,6 +112,7 @@ Name + Org Date Nb Matches @@ -131,6 +136,9 @@ {% endfor %} + + {{ dict_task['org_name'] }}
{{ dict_task['org'] }} + {{ dict_task['date'][0:4]}}/{{ dict_task['date'][4:6]}}/{{ dict_task['date'][6:8]}}

{{dict_task['nb_match']}}

diff --git a/var/www/templates/hunter/show_retro_hunt.html b/var/www/templates/hunter/show_retro_hunt.html index 6afb2f6a..5244fed5 100644 --- a/var/www/templates/hunter/show_retro_hunt.html +++ b/var/www/templates/hunter/show_retro_hunt.html @@ -129,6 +129,10 @@ Creator {{dict_task['creator']}} + + Org + {{dict_task['org_name']}}
{{ dict_task['org'] }} + Filters diff --git a/var/www/templates/hunter/tracker_show.html b/var/www/templates/hunter/tracker_show.html index b6b9ae7b..add8fbcf 100644 --- a/var/www/templates/hunter/tracker_show.html +++ b/var/www/templates/hunter/tracker_show.html @@ -131,6 +131,10 @@ Creator {{meta['user']}} + + Org + {{meta['org_name']}}
{{ meta['org'] }} + First Seen diff --git a/var/www/templates/hunter/trackersManagement.html b/var/www/templates/hunter/trackersManagement.html index 8182d11d..7903f728 100644 --- a/var/www/templates/hunter/trackersManagement.html +++ b/var/www/templates/hunter/trackersManagement.html @@ -58,6 +58,7 @@ Type Tracker + Org First seen Last seen Emails @@ -92,6 +93,9 @@ {% endfor %} + + {{ dict_uuid['org_name'] }}
{{ dict_uuid['org'] }} + {% if dict_uuid['first_seen'] %} {{ dict_uuid['first_seen'][0:4] }}/{{ dict_uuid['first_seen'][4:6] }}/{{ dict_uuid['first_seen'][6:8] }} @@ -130,6 +134,7 @@ Type Tracker + Org First seen Last seen Emails @@ -164,6 +169,9 @@ {% endfor %} + + {{ dict_uuid['org_name'] }}
{{ dict_uuid['org'] }} + {% if dict_uuid['first_seen'] %} {{ dict_uuid['first_seen'][0:4] }}/{{ dict_uuid['first_seen'][4:6] }}/{{ dict_uuid['first_seen'][6:8] }} @@ -199,6 +207,7 @@ Type Tracker + Org First seen Last seen Email notification @@ -233,6 +242,9 @@ {% endfor %} + + {{ dict_uuid['org_name'] }}
{{ dict_uuid['org'] }} + {% if dict_uuid['first_seen'] %} {{ dict_uuid['first_seen'][0:4] }}/{{ dict_uuid['first_seen'][4:6] }}/{{ dict_uuid['first_seen'][6:8] }} diff --git a/var/www/templates/investigations/investigations.html b/var/www/templates/investigations/investigations.html index c7ec711c..f5219612 100644 --- a/var/www/templates/investigations/investigations.html +++ b/var/www/templates/investigations/investigations.html @@ -76,6 +76,7 @@ Name + Org Date last modified Info @@ -95,6 +96,7 @@ + {{ dict_investigation['org_name']}}
{{ dict_investigation['org'] }} {{ dict_investigation['date']}} {{ dict_investigation['last_change']}} {{ dict_investigation['info']}}