mirror of
https://github.com/ail-project/ail-framework.git
synced 2024-11-30 01:37:17 +00:00
fix: tp and fp, errors messages on paste submission
This commit is contained in:
parent
a745b939bd
commit
225776c69c
5 changed files with 18 additions and 18 deletions
|
@ -156,7 +156,7 @@ if __name__ == "__main__":
|
||||||
|
|
||||||
expire_time = 120
|
expire_time = 120
|
||||||
MAX_FILE_SIZE = 1000000000
|
MAX_FILE_SIZE = 1000000000
|
||||||
ALLOWED_EXTENSIONS = 'txt'
|
ALLOWED_EXTENSIONS = ['txt', 'sh', 'pdf']
|
||||||
|
|
||||||
config_section = 'submit_paste'
|
config_section = 'submit_paste'
|
||||||
p = Process(config_section)
|
p = Process(config_section)
|
||||||
|
@ -215,7 +215,7 @@ if __name__ == "__main__":
|
||||||
file_type = filename.rsplit('.', 1)[1]
|
file_type = filename.rsplit('.', 1)[1]
|
||||||
|
|
||||||
#txt file
|
#txt file
|
||||||
if file_type == 'txt':
|
if file_type in ALLOWED_EXTENSIONS:
|
||||||
with open(file_full_path,'r') as f:
|
with open(file_full_path,'r') as f:
|
||||||
content = f.read()
|
content = f.read()
|
||||||
r_serv_log_submit.set(uuid + ':nb_total', 1)
|
r_serv_log_submit.set(uuid + ':nb_total', 1)
|
||||||
|
|
|
@ -56,7 +56,7 @@ PasteSubmit = Blueprint('PasteSubmit', __name__, template_folder='templates')
|
||||||
|
|
||||||
valid_filename_chars = "-_ %s%s" % (string.ascii_letters, string.digits)
|
valid_filename_chars = "-_ %s%s" % (string.ascii_letters, string.digits)
|
||||||
|
|
||||||
ALLOWED_EXTENSIONS = set(['txt', 'zip', 'gz', 'tar.gz'])
|
ALLOWED_EXTENSIONS = set(['txt', 'sh', 'pdf', 'zip', 'gz', 'tar.gz'])
|
||||||
UPLOAD_FOLDER = Flask_config.UPLOAD_FOLDER
|
UPLOAD_FOLDER = Flask_config.UPLOAD_FOLDER
|
||||||
|
|
||||||
misp_event_url = Flask_config.misp_event_url
|
misp_event_url = Flask_config.misp_event_url
|
||||||
|
@ -297,8 +297,8 @@ def submit():
|
||||||
|
|
||||||
if ltags or ltagsgalaxies:
|
if ltags or ltagsgalaxies:
|
||||||
if not addTagsVerification(ltags, ltagsgalaxies):
|
if not addTagsVerification(ltags, ltagsgalaxies):
|
||||||
content = {'INVALID TAGS'}
|
content = 'INVALID TAGS'
|
||||||
return content, status.HTTP_400_BAD_REQUEST
|
return content, 400
|
||||||
|
|
||||||
# add submitted tags
|
# add submitted tags
|
||||||
if(ltags != ''):
|
if(ltags != ''):
|
||||||
|
@ -345,8 +345,8 @@ def submit():
|
||||||
UUID = UUID)
|
UUID = UUID)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
content = {'wrong file type'}
|
content = 'wrong file type, allowed_extensions: sh, pdf, zip, gz, tar.gz or remove the extension'
|
||||||
return content, status.HTTP_400_BAD_REQUEST
|
return content, 400
|
||||||
|
|
||||||
|
|
||||||
elif paste_content != '':
|
elif paste_content != '':
|
||||||
|
@ -365,11 +365,11 @@ def submit():
|
||||||
UUID = UUID)
|
UUID = UUID)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
content = {'size error'}
|
content = 'size error'
|
||||||
return content, status.HTTP_400_BAD_REQUEST
|
return content, 400
|
||||||
|
|
||||||
content = {'submit aborded'}
|
content = 'submit aborded'
|
||||||
return content, status.HTTP_400_BAD_REQUEST
|
return content, 400
|
||||||
|
|
||||||
|
|
||||||
return PasteSubmit_page()
|
return PasteSubmit_page()
|
||||||
|
|
|
@ -308,12 +308,12 @@ def tag_validation():
|
||||||
|
|
||||||
if (status == 'fp' or status == 'tp') and r_serv_tags.sismember('list_tags', tag):
|
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':
|
if status == 'tp':
|
||||||
r_serv_statistics.hdel(tag_hash, 'fp')
|
r_serv_statistics.sadd('tp:'+tag, path)
|
||||||
|
r_serv_statistics.srem('fp:'+tag, path)
|
||||||
else:
|
else:
|
||||||
r_serv_statistics.hdel(tag_hash, 'tp')
|
r_serv_statistics.sadd('fp:'+tag, path)
|
||||||
|
r_serv_statistics.srem('tp:'+tag, path)
|
||||||
|
|
||||||
return redirect(url_for('showsavedpastes.showsavedpaste', paste=path))
|
return redirect(url_for('showsavedpastes.showsavedpaste', paste=path))
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -119,11 +119,11 @@ def showpaste(content_range):
|
||||||
automatic = False
|
automatic = False
|
||||||
|
|
||||||
tag_hash = ssdeep.hash(tag)
|
tag_hash = ssdeep.hash(tag)
|
||||||
if r_serv_statistics.hexists(tag_hash, 'tp'):
|
if r_serv_statistics.sismember('tp:'+tag, requested_path):
|
||||||
tag_status_tp = True
|
tag_status_tp = True
|
||||||
else:
|
else:
|
||||||
tag_status_tp = False
|
tag_status_tp = False
|
||||||
if r_serv_statistics.hexists(tag_hash, 'fp'):
|
if r_serv_statistics.sismember('fp:'+tag, requested_path):
|
||||||
tag_status_fp = True
|
tag_status_fp = True
|
||||||
else:
|
else:
|
||||||
tag_status_fp = False
|
tag_status_fp = False
|
||||||
|
|
Loading…
Reference in a new issue