chg: [trackers + retro_hunts] show organisation

This commit is contained in:
terrtia 2024-09-06 13:46:04 +02:00
parent b030382cdf
commit 478f8f47d1
No known key found for this signature in database
GPG key ID: 1E1B1F50D84613D0
7 changed files with 57 additions and 6 deletions

View file

@ -333,6 +333,8 @@ class Tracker:
'last_seen': self.get_last_seen()} 'last_seen': self.get_last_seen()}
if 'org' in options: if 'org' in options:
meta['org'] = self.get_org() 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: if 'user' in options:
meta['user'] = self.get_user() meta['user'] = self.get_user()
if 'level' in options: if 'level' in options:
@ -725,21 +727,21 @@ def get_user_trackers_meta(user_id, tracker_type=None):
metas = [] metas = []
for tracker_uuid in get_user_trackers(user_id, tracker_type=tracker_type): for tracker_uuid in get_user_trackers(user_id, tracker_type=tracker_type):
tracker = Tracker(tracker_uuid) 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 return metas
def get_global_trackers_meta(tracker_type=None): def get_global_trackers_meta(tracker_type=None):
metas = [] metas = []
for tracker_uuid in get_global_trackers(tracker_type=tracker_type): for tracker_uuid in get_global_trackers(tracker_type=tracker_type):
tracker = Tracker(tracker_uuid) 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 return metas
def get_org_trackers_meta(user_org, tracker_type=None): def get_org_trackers_meta(user_org, tracker_type=None):
metas = [] metas = []
for tracker_uuid in get_org_trackers(user_org, tracker_type=tracker_type): for tracker_uuid in get_org_trackers(user_org, tracker_type=tracker_type):
tracker = Tracker(tracker_uuid) 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 return metas
def get_users_trackers_meta(): def get_users_trackers_meta():
@ -1556,6 +1558,10 @@ class RetroHunt:
meta['nb_match'] = self.get_nb_match() meta['nb_match'] = self.get_nb_match()
if 'nb_objs' in options: if 'nb_objs' in options:
meta['nb_objs'] = self.get_nb_objs() 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: if 'progress' in options:
meta['progress'] = self.get_progress() meta['progress'] = self.get_progress()
if 'filters' in options: if 'filters' in options:
@ -1758,6 +1764,14 @@ def get_retro_hunts_global():
def get_retro_hunts_org(org_uuid): def get_retro_hunts_org(org_uuid):
return ail_orgs.get_org_objs_by_type(org_uuid, 'retro_hunt') 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(): def get_retro_hunt_pending_tasks():
return r_tracker.smembers('retro_hunts:pending') return r_tracker.smembers('retro_hunts:pending')
@ -1785,7 +1799,7 @@ def get_retro_hunt_metas(trackers_uuid):
tasks = [] tasks = []
for task_uuid in trackers_uuid: for task_uuid in trackers_uuid:
retro_hunt = RetroHunt(task_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 return tasks
## Objects ## ## Objects ##

View file

@ -167,7 +167,7 @@ def show_tracker():
date_to = date_to.replace('-', '') date_to = date_to.replace('-', '')
tracker = Tracker.Tracker(tracker_uuid) 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'}) 'user', 'webhooks', 'nb_objs'})
if meta['type'] == 'yara': 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)) 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) 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']) @hunters.route('/retro_hunt/task/show', methods=['GET'])
@login_required @login_required
@login_read_only @login_read_only
@ -512,7 +519,7 @@ def retro_hunt_show_task():
if res: if res:
return 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']) rule_content = Tracker.get_yara_rule_content(dict_task['rule'])
dict_task['filters'] = json.dumps(dict_task['filters'], indent=4) dict_task['filters'] = json.dumps(dict_task['filters'], indent=4)

View file

@ -41,6 +41,7 @@
<thead class="bg-dark text-white"> <thead class="bg-dark text-white">
<tr> <tr>
<th>Name</th> <th>Name</th>
<th>Org</th>
<th>Date</th> <th>Date</th>
<th>Nb Matches</th> <th>Nb Matches</th>
<th></th> <th></th>
@ -64,6 +65,9 @@
{% endfor %} {% endfor %}
</div> </div>
</td> </td>
<td>
{{ dict_task['org_name'] }}<br>{{ dict_task['org'] }}
</td>
<td>{{ dict_task['date'][0:4]}}/{{ dict_task['date'][4:6]}}/{{ dict_task['date'][6:8]}}</td> <td>{{ dict_task['date'][0:4]}}/{{ dict_task['date'][4:6]}}/{{ dict_task['date'][6:8]}}</td>
<td> <td>
<b><h3 class="font-weight-bold text-primary">{{dict_task['nb_match']}}</h3></b> <b><h3 class="font-weight-bold text-primary">{{dict_task['nb_match']}}</h3></b>
@ -108,6 +112,7 @@
<thead class="bg-dark text-white"> <thead class="bg-dark text-white">
<tr> <tr>
<th>Name</th> <th>Name</th>
<th>Org</th>
<th>Date</th> <th>Date</th>
<th>Nb Matches</th> <th>Nb Matches</th>
<th></th> <th></th>
@ -131,6 +136,9 @@
{% endfor %} {% endfor %}
</div> </div>
</td> </td>
<td>
{{ dict_task['org_name'] }}<br>{{ dict_task['org'] }}
</td>
<td>{{ dict_task['date'][0:4]}}/{{ dict_task['date'][4:6]}}/{{ dict_task['date'][6:8]}}</td> <td>{{ dict_task['date'][0:4]}}/{{ dict_task['date'][4:6]}}/{{ dict_task['date'][6:8]}}</td>
<td> <td>
<b><h3 class="font-weight-bold text-primary">{{dict_task['nb_match']}}</h3></b> <b><h3 class="font-weight-bold text-primary">{{dict_task['nb_match']}}</h3></b>

View file

@ -129,6 +129,10 @@
<td class="text-right"><b>Creator</b></td> <td class="text-right"><b>Creator</b></td>
<td>{{dict_task['creator']}}</td> <td>{{dict_task['creator']}}</td>
</tr> </tr>
<tr>
<td class="text-right"><b>Org</b></td>
<td>{{dict_task['org_name']}}<br>{{ dict_task['org'] }}</td>
</tr>
<tr> <tr>
<td class="text-right"><b>Filters</b></td> <td class="text-right"><b>Filters</b></td>
<td> <td>

View file

@ -131,6 +131,10 @@
<td class="text-right"><b>Creator</b></td> <td class="text-right"><b>Creator</b></td>
<td>{{meta['user']}}</td> <td>{{meta['user']}}</td>
</tr> </tr>
<tr>
<td class="text-right"><b>Org</b></td>
<td>{{meta['org_name']}}<br>{{ meta['org'] }}</td>
</tr>
<tr> <tr>
<td class="text-right"><b>First Seen</b></td> <td class="text-right"><b>First Seen</b></td>
<td> <td>

View file

@ -58,6 +58,7 @@
<tr> <tr>
<th>Type</th> <th>Type</th>
<th>Tracker</th> <th>Tracker</th>
<th>Org</th>
<th>First seen</th> <th>First seen</th>
<th>Last seen</th> <th>Last seen</th>
<th>Emails</th> <th>Emails</th>
@ -92,6 +93,9 @@
{% endfor %} {% endfor %}
</div> </div>
</td> </td>
<td>
{{ dict_uuid['org_name'] }}<br>{{ dict_uuid['org'] }}
</td>
<td> <td>
{% if dict_uuid['first_seen'] %} {% if dict_uuid['first_seen'] %}
{{ dict_uuid['first_seen'][0:4] }}/{{ dict_uuid['first_seen'][4:6] }}/{{ dict_uuid['first_seen'][6:8] }} {{ dict_uuid['first_seen'][0:4] }}/{{ dict_uuid['first_seen'][4:6] }}/{{ dict_uuid['first_seen'][6:8] }}
@ -130,6 +134,7 @@
<tr> <tr>
<th>Type</th> <th>Type</th>
<th>Tracker</th> <th>Tracker</th>
<th>Org</th>
<th>First seen</th> <th>First seen</th>
<th>Last seen</th> <th>Last seen</th>
<th>Emails</th> <th>Emails</th>
@ -164,6 +169,9 @@
{% endfor %} {% endfor %}
</div> </div>
</td> </td>
<td>
{{ dict_uuid['org_name'] }}<br>{{ dict_uuid['org'] }}
</td>
<td> <td>
{% if dict_uuid['first_seen'] %} {% if dict_uuid['first_seen'] %}
{{ dict_uuid['first_seen'][0:4] }}/{{ dict_uuid['first_seen'][4:6] }}/{{ dict_uuid['first_seen'][6:8] }} {{ dict_uuid['first_seen'][0:4] }}/{{ dict_uuid['first_seen'][4:6] }}/{{ dict_uuid['first_seen'][6:8] }}
@ -199,6 +207,7 @@
<tr> <tr>
<th>Type</th> <th>Type</th>
<th>Tracker</th> <th>Tracker</th>
<th>Org</th>
<th>First seen</th> <th>First seen</th>
<th>Last seen</th> <th>Last seen</th>
<th>Email notification</th> <th>Email notification</th>
@ -233,6 +242,9 @@
{% endfor %} {% endfor %}
</div> </div>
</td> </td>
<td>
{{ dict_uuid['org_name'] }}<br>{{ dict_uuid['org'] }}
</td>
<td> <td>
{% if dict_uuid['first_seen'] %} {% if dict_uuid['first_seen'] %}
{{ dict_uuid['first_seen'][0:4] }}/{{ dict_uuid['first_seen'][4:6] }}/{{ dict_uuid['first_seen'][6:8] }} {{ dict_uuid['first_seen'][0:4] }}/{{ dict_uuid['first_seen'][4:6] }}/{{ dict_uuid['first_seen'][6:8] }}

View file

@ -76,6 +76,7 @@
<thead class="bg-dark text-white"> <thead class="bg-dark text-white">
<tr> <tr>
<th>Name</th> <th>Name</th>
<th>Org</th>
<th>Date</th> <th>Date</th>
<th>last modified</th> <th>last modified</th>
<td>Info</td> <td>Info</td>
@ -95,6 +96,7 @@
</div> </div>
</a> </a>
</td> </td>
<td>{{ dict_investigation['org_name']}}<br>{{ dict_investigation['org'] }}</td>
<td>{{ dict_investigation['date']}}</td> <td>{{ dict_investigation['date']}}</td>
<td>{{ dict_investigation['last_change']}}</td> <td>{{ dict_investigation['last_change']}}</td>
<td>{{ dict_investigation['info']}}</td> <td>{{ dict_investigation['info']}}</td>