fix duplicate + get raw paste

This commit is contained in:
Terrtia 2018-05-11 16:07:30 +02:00
parent d7ba5533be
commit 225fe76c96
No known key found for this signature in database
GPG key ID: 1E1B1F50D84613D0
4 changed files with 12 additions and 8 deletions

View file

@ -118,7 +118,6 @@ if __name__ == "__main__":
for curr_dico_name, curr_dico_redis in opened_dico:
for hash_type, paste_hash in paste_hashes.items():
for dico_hash in curr_dico_redis.smembers('HASHS_'+hash_type):
dico_hash = dico_hash
try:
if hash_type == 'ssdeep':

View file

@ -333,13 +333,11 @@ class Paste(object):
#json save on redis
if json_duplicate is not None:
list_duplicate = (json.loads(json_duplicate))
# avoid duplicate
list_duplicate = set(tuple(row) for row in list_duplicate)
list_duplicate = [list(item) for item in set(tuple(row) for row in list_duplicate)]
# add new duplicate
list_duplicate.append([hash_type, self.p_path, percent, date])
self.store.hset(path, attr_name, json.dumps(list_duplicate))
# avoid duplicate, a paste can be send by multiples modules
to_add = [hash_type, self.p_path, percent, date]
if to_add not in list_duplicate:
list_duplicate.append(to_add)
self.store.hset(path, attr_name, json.dumps(list_duplicate))
else:
# create the new list

View file

@ -101,6 +101,12 @@ def showpaste(content_range):
def showsavedpaste():
return showpaste(0)
@showsavedpastes.route("/showsavedrawpaste/") #shows raw
def showsavedrawpaste():
requested_path = request.args.get('paste', '')
paste = Paste.Paste(requested_path)
content = paste.get_p_content()
return content, 200, {'Content-Type': 'text/plain'}
@showsavedpastes.route("/showpreviewpaste/")
def showpreviewpaste():

View file

@ -80,6 +80,7 @@
</table>
{% endif %}
<h3> Content: </h3>
<a href="{{ url_for('showsavedpastes.showsavedrawpaste') }}?paste={{ request.args.get('paste') }}" id='raw_paste' > [Raw content] </a>
<p data-initsize="{{ initsize }}"> <pre id="paste-holder">{{ content }}</pre></p>
</div>
</div>