add tag fp and tp

This commit is contained in:
Terrtia 2018-06-19 15:09:26 +02:00
parent bf72c27711
commit af9db53171
No known key found for this signature in database
GPG key ID: 1E1B1F50D84613D0
5 changed files with 71 additions and 2 deletions

View file

@ -162,6 +162,11 @@ host = localhost
port = 6382
db = 7
[ARDB_Statistics]
host = localhost
port = 6382
db = 8
[Url]
cc_critical = DE

View file

@ -90,6 +90,12 @@ r_serv_db = redis.StrictRedis(
db=cfg.getint("ARDB_DB", "db"),
decode_responses=True)
r_serv_statistics = redis.StrictRedis(
host=cfg.get("ARDB_Statistics", "host"),
port=cfg.getint("ARDB_Statistics", "port"),
db=cfg.getint("ARDB_Statistics", "db"),
decode_responses=True)
sys.path.append('../../configs/keys')
# MISP #

View file

@ -9,6 +9,7 @@ from flask import Flask, render_template, jsonify, request, Blueprint, redirect,
import json
from datetime import datetime
import ssdeep
import Paste
@ -22,6 +23,7 @@ app = Flask_config.app
cfg = Flask_config.cfg
r_serv_tags = Flask_config.r_serv_tags
r_serv_metadata = Flask_config.r_serv_metadata
r_serv_statistics = Flask_config.r_serv_statistics
max_preview_char = Flask_config.max_preview_char
max_preview_modal = Flask_config.max_preview_modal
bootstrap_label = Flask_config.bootstrap_label
@ -297,6 +299,26 @@ def confirm_tag():
return 'incompatible tag'
@Tags.route("/Tags/tag_validation")
def tag_validation():
path = request.args.get('paste')
tag = request.args.get('tag')
status = request.args.get('status')
if (status == 'fp' or status == 'tp') and r_serv_tags.sismember('list_tags', tag):
tag_hash = ssdeep.hash(tag)
r_serv_statistics.hset(tag_hash, status, path)
if status == 'tp':
r_serv_statistics.hdel(tag_hash, 'fp')
else:
r_serv_statistics.hdel(tag_hash, 'tp')
return redirect(url_for('showsavedpastes.showsavedpaste', paste=path))
else:
return 'input error'
@Tags.route("/Tags/addTags")
def addTags():

View file

@ -9,6 +9,7 @@ import json
import flask
from flask import Flask, render_template, jsonify, request, Blueprint, make_response
import difflib
import ssdeep
import Paste
@ -20,6 +21,7 @@ cfg = Flask_config.cfg
r_serv_pasteName = Flask_config.r_serv_pasteName
r_serv_metadata = Flask_config.r_serv_metadata
r_serv_tags = Flask_config.r_serv_tags
r_serv_statistics = Flask_config.r_serv_statistics
max_preview_char = Flask_config.max_preview_char
max_preview_modal = Flask_config.max_preview_modal
DiffMaxLineLength = Flask_config.DiffMaxLineLength
@ -112,9 +114,21 @@ def showpaste(content_range):
for tag in l_tags:
if(tag[9:28] == 'automatic-detection'):
list_tags.append( (tag, True) )
automatic = True
else:
list_tags.append( (tag, False) )
automatic = False
tag_hash = ssdeep.hash(tag)
if r_serv_statistics.hexists(tag_hash, 'tp'):
tag_status_tp = True
else:
tag_status_tp = False
if r_serv_statistics.hexists(tag_hash, 'fp'):
tag_status_fp = True
else:
tag_status_fp = False
list_tags.append( (tag, automatic, tag_status_tp, tag_status_fp) )
if Flask_config.pymisp is False:
misp = False

View file

@ -122,6 +122,28 @@
<span class="label label-{{ bootstrap_label[loop.index0 % 5] }}" >{{ tag[0] }}</span>
</div>
<div class="modal-footer center">
{% if not tag[2] %}
<a href="{{ url_for('Tags.tag_validation') }}?paste={{ request.args.get('paste') }}&tag={{ tag[0] }}&status=tp" class="btn btn-success pull-left" data-toggle="tooltip" title="Good Detection">
<span class="glyphicon glyphicon-thumbs-up "></span>
</a>
{% endif %}
{% if tag[2] %}
<button class="btn btn-success pull-left disabled" data-toggle="tooltip" title="Good Detection">
<span class="glyphicon glyphicon-thumbs-up "></span>
</button>
{% endif %}
{% if not tag[3] %}
<a href="{{ url_for('Tags.tag_validation') }}?paste={{ request.args.get('paste') }}&tag={{ tag[0] }}&status=fp" class="btn btn-danger pull-left" data-toggle="tooltip" title="Bad Detection">
<span class="glyphicon glyphicon-thumbs-down "></span>
</a>
{% endif %}
{% if tag[3] %}
<button class="btn btn-danger pull-left disabled" data-toggle="tooltip" title="Bad Detection">
<span class="glyphicon glyphicon-thumbs-down "></span>
</button>
{% endif %}
{% if tag[1] %}
<a href="{{ url_for('Tags.confirm_tag') }}?paste={{ request.args.get('paste') }}&tag={{ tag[0] }}" class="btn btn-primary">
<span class="glyphicon glyphicon-ok "></span> Confirm this Tag