mirror of https://github.com/CIRCL/AIL-framework
Add initial UI support for Webhook in tracker
parent
b3b30616b2
commit
06a886732c
|
@ -106,6 +106,9 @@ def get_tracker_tags(tracker_uuid):
|
||||||
def get_tracker_mails(tracker_uuid):
|
def get_tracker_mails(tracker_uuid):
|
||||||
return list(r_serv_tracker.smembers('tracker:mail:{}'.format(tracker_uuid)))
|
return list(r_serv_tracker.smembers('tracker:mail:{}'.format(tracker_uuid)))
|
||||||
|
|
||||||
|
def get_tracker_webhook(tracker_uuid):
|
||||||
|
return r_serv_tracker.hget('tracker:{}'.format(tracker_uuid), 'webhook')
|
||||||
|
|
||||||
def get_tracker_uuid_sources(tracker_uuid):
|
def get_tracker_uuid_sources(tracker_uuid):
|
||||||
return list(r_serv_tracker.smembers(f'tracker:sources:{tracker_uuid}'))
|
return list(r_serv_tracker.smembers(f'tracker:sources:{tracker_uuid}'))
|
||||||
|
|
||||||
|
@ -129,7 +132,7 @@ def get_tracker_last_seen(tracker_uuid):
|
||||||
else:
|
else:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def get_tracker_metedata(tracker_uuid, user_id=False, description=False, level=False, tags=False, mails=False, sources=True, sparkline=False):
|
def get_tracker_metedata(tracker_uuid, user_id=False, description=False, level=False, tags=False, mails=False, sources=True, sparkline=False, webhook=False):
|
||||||
dict_uuid = {}
|
dict_uuid = {}
|
||||||
dict_uuid['tracker'] = get_tracker_by_uuid(tracker_uuid)
|
dict_uuid['tracker'] = get_tracker_by_uuid(tracker_uuid)
|
||||||
dict_uuid['type'] = get_tracker_type(tracker_uuid)
|
dict_uuid['type'] = get_tracker_type(tracker_uuid)
|
||||||
|
@ -149,6 +152,8 @@ def get_tracker_metedata(tracker_uuid, user_id=False, description=False, level=F
|
||||||
dict_uuid['tags'] = get_tracker_tags(tracker_uuid)
|
dict_uuid['tags'] = get_tracker_tags(tracker_uuid)
|
||||||
if sparkline:
|
if sparkline:
|
||||||
dict_uuid['sparkline'] = get_tracker_sparkline(tracker_uuid)
|
dict_uuid['sparkline'] = get_tracker_sparkline(tracker_uuid)
|
||||||
|
if webhook:
|
||||||
|
dict_uuid['webhook'] = get_tracker_webhook(tracker_uuid)
|
||||||
dict_uuid['uuid'] = tracker_uuid
|
dict_uuid['uuid'] = tracker_uuid
|
||||||
return dict_uuid
|
return dict_uuid
|
||||||
|
|
||||||
|
|
|
@ -96,6 +96,7 @@ def add_tracked_menu():
|
||||||
tracker_type = request.form.get("tracker_type")
|
tracker_type = request.form.get("tracker_type")
|
||||||
nb_words = request.form.get("nb_word", 1)
|
nb_words = request.form.get("nb_word", 1)
|
||||||
description = request.form.get("description", '')
|
description = request.form.get("description", '')
|
||||||
|
webhook = request.form.get("webhook", '')
|
||||||
level = request.form.get("level", 0)
|
level = request.form.get("level", 0)
|
||||||
tags = request.form.get("tags", [])
|
tags = request.form.get("tags", [])
|
||||||
mails = request.form.get("mails", [])
|
mails = request.form.get("mails", [])
|
||||||
|
@ -125,7 +126,7 @@ def add_tracked_menu():
|
||||||
|
|
||||||
input_dict = {"tracker": tracker, "type": tracker_type, "nb_words": nb_words,
|
input_dict = {"tracker": tracker, "type": tracker_type, "nb_words": nb_words,
|
||||||
"tags": tags, "mails": mails, "sources": sources,
|
"tags": tags, "mails": mails, "sources": sources,
|
||||||
"level": level, "description": description}
|
"level": level, "description": description, "webhook": webhook}
|
||||||
user_id = current_user.get_id()
|
user_id = current_user.get_id()
|
||||||
# edit tracker
|
# edit tracker
|
||||||
if tracker_uuid:
|
if tracker_uuid:
|
||||||
|
@ -155,7 +156,7 @@ def edit_tracked_menu():
|
||||||
if res: # invalid access
|
if res: # invalid access
|
||||||
return Response(json.dumps(res[0], indent=2, sort_keys=True), mimetype='application/json'), res[1]
|
return Response(json.dumps(res[0], indent=2, sort_keys=True), mimetype='application/json'), res[1]
|
||||||
|
|
||||||
dict_tracker = Tracker.get_tracker_metedata(tracker_uuid, user_id=True, level=True, description=True, tags=True, mails=True, sources=True)
|
dict_tracker = Tracker.get_tracker_metedata(tracker_uuid, user_id=True, level=True, description=True, tags=True, mails=True, sources=True, webhook=True)
|
||||||
dict_tracker['tags'] = ' '.join(dict_tracker['tags'])
|
dict_tracker['tags'] = ' '.join(dict_tracker['tags'])
|
||||||
dict_tracker['mails'] = ' '.join(dict_tracker['mails'])
|
dict_tracker['mails'] = ' '.join(dict_tracker['mails'])
|
||||||
|
|
||||||
|
@ -202,7 +203,7 @@ def show_tracker():
|
||||||
if date_to:
|
if date_to:
|
||||||
date_to = date_to.replace('-', '')
|
date_to = date_to.replace('-', '')
|
||||||
|
|
||||||
tracker_metadata = Tracker.get_tracker_metedata(tracker_uuid, user_id=True, level=True, description=True, tags=True, mails=True, sources=True, sparkline=True)
|
tracker_metadata = Tracker.get_tracker_metedata(tracker_uuid, user_id=True, level=True, description=True, tags=True, mails=True, sources=True, sparkline=True, webhook=True)
|
||||||
|
|
||||||
if tracker_metadata['type'] == 'yara':
|
if tracker_metadata['type'] == 'yara':
|
||||||
yara_rule_content = Tracker.get_yara_rule_content(tracker_metadata['tracker'])
|
yara_rule_content = Tracker.get_yara_rule_content(tracker_metadata['tracker'])
|
||||||
|
|
|
@ -43,7 +43,7 @@
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-12 col-xl-9">
|
<div class="col-12 col-xl-9">
|
||||||
<div class="input-group mb-2 mr-sm-2">
|
<div class="input-group mb-2 mr-sm-2">
|
||||||
<div class="input-group-prepend">
|
<div class="input-group-prepend"-->
|
||||||
<div class="input-group-text bg-danger text-white"><i class="fas fa-tag"></i></div>
|
<div class="input-group-text bg-danger text-white"><i class="fas fa-tag"></i></div>
|
||||||
</div>
|
</div>
|
||||||
<input id="tags" name="tags" class="form-control" placeholder="Tags (optional, space separated)" type="text" {%if dict_tracker%}{%if dict_tracker['tags']%}value="{{dict_tracker['tags']}}"{%endif%}{%endif%}>
|
<input id="tags" name="tags" class="form-control" placeholder="Tags (optional, space separated)" type="text" {%if dict_tracker%}{%if dict_tracker['tags']%}value="{{dict_tracker['tags']}}"{%endif%}{%endif%}>
|
||||||
|
@ -53,6 +53,12 @@
|
||||||
<div class="input-group-text bg-secondary text-white"><i class="fas fa-at"></i></div>
|
<div class="input-group-text bg-secondary text-white"><i class="fas fa-at"></i></div>
|
||||||
</div>
|
</div>
|
||||||
<input id="mails" name="mails" class="form-control" placeholder="E-Mails Notification (optional, space separated)" type="text" {%if dict_tracker%}{%if dict_tracker['mails']%}value="{{dict_tracker['mails']}}"{%endif%}{%endif%}>
|
<input id="mails" name="mails" class="form-control" placeholder="E-Mails Notification (optional, space separated)" type="text" {%if dict_tracker%}{%if dict_tracker['mails']%}value="{{dict_tracker['mails']}}"{%endif%}{%endif%}>
|
||||||
|
</div>
|
||||||
|
<div class="input-group mb-2 mr-sm-2">
|
||||||
|
<div class="input-group-prepend">
|
||||||
|
<div class="input-group-text bg-secondary text-white"><i class="fas fa-at"></i></div>
|
||||||
|
</div>
|
||||||
|
<input id="webhook" name="webhook" class="form-control" placeholder="Webhook URL" type="text" {%if dict_tracker%}{%if dict_tracker['webhook']%}value="{{dict_tracker['webhook']}}"{%endif%}{%endif%}>
|
||||||
</div>
|
</div>
|
||||||
<div class="input-group mb-2 mr-sm-2">
|
<div class="input-group mb-2 mr-sm-2">
|
||||||
<div class="input-group-prepend">
|
<div class="input-group-prepend">
|
||||||
|
|
|
@ -74,6 +74,7 @@
|
||||||
<th>Created by</th>
|
<th>Created by</th>
|
||||||
<th>First seen</th>
|
<th>First seen</th>
|
||||||
<th>Last seen</th>
|
<th>Last seen</th>
|
||||||
|
<th>Webhook URL</th>
|
||||||
<th>Tags <span class="btn-link btn-interaction mouse_pointer" title="Edit Tags List" onclick="edit_tags();"><i class="fas fa-pencil-alt" style="color:Red;"></i></span></th>
|
<th>Tags <span class="btn-link btn-interaction mouse_pointer" title="Edit Tags List" onclick="edit_tags();"><i class="fas fa-pencil-alt" style="color:Red;"></i></span></th>
|
||||||
<th>Email <span class="btn-link btn-interaction mouse_pointer" title="Edit Email List" onclick="edit_mails();"><i class="fas fa-pencil-alt" style="color:Red;"></i></span></th>
|
<th>Email <span class="btn-link btn-interaction mouse_pointer" title="Edit Email List" onclick="edit_mails();"><i class="fas fa-pencil-alt" style="color:Red;"></i></span></th>
|
||||||
</tr>
|
</tr>
|
||||||
|
@ -95,6 +96,11 @@
|
||||||
{{ tracker_metadata['last_seen'][0:4] }}/{{ tracker_metadata['last_seen'][4:6] }}/{{ tracker_metadata['last_seen'][6:8] }}
|
{{ tracker_metadata['last_seen'][0:4] }}/{{ tracker_metadata['last_seen'][4:6] }}/{{ tracker_metadata['last_seen'][6:8] }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</td>
|
</td>
|
||||||
|
<td>
|
||||||
|
{% if tracker_metadata['wehook'] %}
|
||||||
|
{{ tracker_metadata['wehook'] }}
|
||||||
|
{% endif %}
|
||||||
|
</td>
|
||||||
<td>
|
<td>
|
||||||
{% for tag in tracker_metadata['tags'] %}
|
{% for tag in tracker_metadata['tags'] %}
|
||||||
<a href="{{ url_for('tags_ui.get_obj_by_tags') }}?object_type=item<ags={{ tag }}">
|
<a href="{{ url_for('tags_ui.get_obj_by_tags') }}?object_type=item<ags={{ tag }}">
|
||||||
|
|
|
@ -25,9 +25,11 @@
|
||||||
.btn-link {
|
.btn-link {
|
||||||
color: #000000
|
color: #000000
|
||||||
}
|
}
|
||||||
|
|
||||||
.mouse_pointer {
|
.mouse_pointer {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
.lb-md {
|
.lb-md {
|
||||||
font-size: 16px;
|
font-size: 16px;
|
||||||
}
|
}
|
||||||
|
@ -56,6 +58,7 @@
|
||||||
<th>Tracker</th>
|
<th>Tracker</th>
|
||||||
<th>First seen</th>
|
<th>First seen</th>
|
||||||
<th>Last seen</th>
|
<th>Last seen</th>
|
||||||
|
<th>Webhook URL</th>
|
||||||
<th>Email notification</th>
|
<th>Email notification</th>
|
||||||
<th>sparkline</th>
|
<th>sparkline</th>
|
||||||
</tr>
|
</tr>
|
||||||
|
@ -86,12 +89,19 @@
|
||||||
</td>
|
</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] }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
{% if dict_uuid['last_seen'] %}
|
{% if dict_uuid['last_seen'] %}
|
||||||
{{dict_uuid['last_seen'][0:4]}}/{{dict_uuid['last_seen'][4:6]}}/{{dict_uuid['last_seen'][6:8]}}
|
{{ dict_uuid['last_seen'][0:4] }}/{{ dict_uuid['last_seen'][4:6] }}/
|
||||||
|
{{ dict_uuid['last_seen'][6:8] }}
|
||||||
|
{% endif %}
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
{% if dict_uuid['webhook'] %}
|
||||||
|
{{ dict_uuid['webhook'] }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
|
@ -119,6 +129,7 @@
|
||||||
<th>Tracker</th>
|
<th>Tracker</th>
|
||||||
<th>First seen</th>
|
<th>First seen</th>
|
||||||
<th>Last seen</th>
|
<th>Last seen</th>
|
||||||
|
<th>Webhook URL</th>
|
||||||
<th>Email notification</th>
|
<th>Email notification</th>
|
||||||
<th>sparkline</th>
|
<th>sparkline</th>
|
||||||
</tr>
|
</tr>
|
||||||
|
@ -149,12 +160,19 @@
|
||||||
</td>
|
</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] }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
{% if dict_uuid['last_seen'] %}
|
{% if dict_uuid['last_seen'] %}
|
||||||
{{dict_uuid['last_seen'][0:4]}}/{{dict_uuid['last_seen'][4:6]}}/{{dict_uuid['last_seen'][6:8]}}
|
{{ dict_uuid['last_seen'][0:4] }}/{{ dict_uuid['last_seen'][4:6] }}/
|
||||||
|
{{ dict_uuid['last_seen'][6:8] }}
|
||||||
|
{% endif %}
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
{% if dict_uuid['webhook'] %}
|
||||||
|
{{ dict_uuid['webhook'] }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
|
@ -171,7 +189,6 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<a class="btn btn-info my-4" href="{{ url_for('hunter.add_tracked_menu') }}">
|
<a class="btn btn-info my-4" href="{{ url_for('hunter.add_tracked_menu') }}">
|
||||||
<i class="fas fa-plus-circle ml-auto"></i>
|
<i class="fas fa-plus-circle ml-auto"></i>
|
||||||
Create New Tracker
|
Create New Tracker
|
||||||
|
|
Loading…
Reference in New Issue