mirror of
https://github.com/ail-project/ail-framework.git
synced 2024-11-27 00:07:16 +00:00
add and delete tags features
This commit is contained in:
parent
4fbbf8bbd2
commit
b9eb3ed9ba
3 changed files with 77 additions and 3 deletions
|
@ -5,7 +5,7 @@
|
||||||
Flask functions and routes for the trending modules page
|
Flask functions and routes for the trending modules page
|
||||||
'''
|
'''
|
||||||
import redis
|
import redis
|
||||||
from flask import Flask, render_template, jsonify, request, Blueprint
|
from flask import Flask, render_template, jsonify, request, Blueprint, redirect, url_for
|
||||||
|
|
||||||
import json
|
import json
|
||||||
|
|
||||||
|
@ -146,5 +146,43 @@ def get_tagged_paste_res():
|
||||||
|
|
||||||
return render_template("res.html")
|
return render_template("res.html")
|
||||||
|
|
||||||
|
@Tags.route("/Tags/remove_tag")
|
||||||
|
def remove_tag():
|
||||||
|
|
||||||
|
#TODO verify input
|
||||||
|
path = request.args.get('paste')
|
||||||
|
tag = request.args.get('tag')
|
||||||
|
|
||||||
|
#remove tag
|
||||||
|
r_serv_metadata.srem('tag:'+path, tag)
|
||||||
|
r_serv_tags.srem(tag, path)
|
||||||
|
|
||||||
|
return redirect(url_for('showsavedpastes.showsavedpaste', paste=path))
|
||||||
|
|
||||||
|
@Tags.route("/Tags/confirm_tag")
|
||||||
|
def confirm_tag():
|
||||||
|
|
||||||
|
#TODO verify input
|
||||||
|
path = request.args.get('paste')
|
||||||
|
tag = request.args.get('tag')
|
||||||
|
|
||||||
|
if(tag[9:28] == 'automatic-detection'):
|
||||||
|
|
||||||
|
#remove automatic tag
|
||||||
|
r_serv_metadata.srem('tag:'+path, tag)
|
||||||
|
r_serv_tags.srem(tag, path)
|
||||||
|
|
||||||
|
tag = tag.replace('automatic-detection','analyst-detection', 1)
|
||||||
|
#add analyst tag
|
||||||
|
r_serv_metadata.sadd('tag:'+path, tag)
|
||||||
|
r_serv_tags.sadd(tag, path)
|
||||||
|
#add new tag in list of all used tags
|
||||||
|
r_serv_tags.sadd('list_tags', tag)
|
||||||
|
|
||||||
|
return redirect(url_for('showsavedpastes.showsavedpaste', paste=path))
|
||||||
|
|
||||||
|
return 'incompatible tag'
|
||||||
|
|
||||||
|
|
||||||
# ========= REGISTRATION =========
|
# ========= REGISTRATION =========
|
||||||
app.register_blueprint(Tags)
|
app.register_blueprint(Tags)
|
||||||
|
|
|
@ -168,7 +168,7 @@ $(document).ready(function(){
|
||||||
|
|
||||||
var ltags = $('#ltags').tagSuggest({
|
var ltags = $('#ltags').tagSuggest({
|
||||||
data: data,
|
data: data,
|
||||||
//value: slct_tags,
|
value: '["infoleak:automatic-detection=\"bitcoin-address\"","infoleak:automatic-detection=\"aws-key\""]',
|
||||||
sortOrder: 'name',
|
sortOrder: 'name',
|
||||||
maxDropHeight: 200,
|
maxDropHeight: 200,
|
||||||
name: 'ltags'
|
name: 'ltags'
|
||||||
|
|
|
@ -24,8 +24,37 @@
|
||||||
<h2 class="page-header" >
|
<h2 class="page-header" >
|
||||||
<div>
|
<div>
|
||||||
{% for tag in list_tags %}
|
{% for tag in list_tags %}
|
||||||
<span class="label label-{{ bootstrap_label[loop.index0 % 6] }} pull-left">{{ tag }}</span>
|
<span class="btn btn-{{ bootstrap_label[loop.index0 % 6] }} btn-lg pull-left" data-toggle="modal" data-target="#myModal_{{ loop.index0 }}">{{ tag }}</span>
|
||||||
|
|
||||||
|
<!-- Modal edit this tag -->
|
||||||
|
<div class="modal fade" id="myModal_{{ loop.index0 }}" role="dialog">
|
||||||
|
<div class="modal-dialog">
|
||||||
|
|
||||||
|
<div class="modal-content text-center">
|
||||||
|
<div class="modal-header" style="border-bottom: 4px solid #cccccc; background-color: #cccccc; color: #ffffff;">
|
||||||
|
<p class="heading">Edit this tag</p>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<div class="modal-body">
|
||||||
|
<span class="label label-{{ bootstrap_label[loop.index0 % 6] }}" >{{ tag }}</span>
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer center">
|
||||||
|
<a href="{{ url_for('Tags.confirm_tag') }}?paste={{ request.args.get('paste') }}&tag={{ tag }}" class="btn btn-primary">
|
||||||
|
<span class="glyphicon glyphicon-ok "></span> Confirm this Tag
|
||||||
|
</a>
|
||||||
|
<a href="{{ url_for('Tags.remove_tag') }}?paste={{ request.args.get('paste') }}&tag={{ tag }}" class="btn btn-danger">
|
||||||
|
<span class="glyphicon glyphicon-trash "></span> Delete this Tag
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
<button type="button" class="btn btn-light btn-lg" data-toggle="tooltip" title="Add Tag">
|
||||||
|
<span class="glyphicon glyphicon-plus "></span>
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</h2>
|
</h2>
|
||||||
|
|
||||||
|
@ -55,6 +84,13 @@
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
|
<button type="button" class="btn btn-success btn-lg" data-toggle="tooltip" title="Good Detection">
|
||||||
|
<span class="glyphicon glyphicon-thumbs-up "></span>
|
||||||
|
</span>
|
||||||
|
<button type="button" class="btn btn-danger btn-lg" data-toggle="tooltip" title="Bad Detection">
|
||||||
|
<span class="glyphicon glyphicon-thumbs-down "></span>
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="panel-body" id="panel-body">
|
<div class="panel-body" id="panel-body">
|
||||||
{% if duplicate_list|length == 0 %}
|
{% if duplicate_list|length == 0 %}
|
||||||
|
|
Loading…
Reference in a new issue