add img + fix upload api

pull/208/head
Terrtia 2018-06-18 17:16:22 +02:00
parent 704e6f0ad1
commit 634bf6e552
No known key found for this signature in database
GPG Key ID: 1E1B1F50D84613D0
5 changed files with 21 additions and 14 deletions

View File

@ -201,10 +201,14 @@ if __name__ == "__main__":
filename = file_full_path.split('/')[-1]
if not '.' in filename:
# read file
try:
with open(file_full_path,'r') as f:
content = f.read()
except:
abord_file_submission(uuid, "file error")
continue
r_serv_log_submit.set(uuid + ':nb_total', 1)
create_paste(uuid, content.encode(), ltags, ltagsgalaxies, uuid)
create_paste(uuid, content, ltags, ltagsgalaxies, uuid)
remove_submit_uuid(uuid)
else:

View File

@ -179,7 +179,7 @@ def misp_create_event(distribution, threat_level_id, analysis, info, l_tags, pub
eventUuid = event['Event']['uuid']
eventid = event['Event']['id']
r_serv_metadata.set('misp_events:path', eventid)
r_serv_metadata.set('misp_events:'+path, eventid)
# add tags
for tag in l_tags:
@ -192,8 +192,6 @@ def misp_create_event(distribution, threat_level_id, analysis, info, l_tags, pub
leak_obj.add_attribute('origin', value=source, type='text')
leak_obj.add_attribute('last-seen', value=date_to_str(paste.p_date), type='datetime')
leak_obj.add_attribute('raw-data', value=source, data=pseudofile, type="attachment")
# FIXME TODO: delete this
leak_obj.add_attribute('type', value='Onion', type='text')
if p_duplicate_number > 0:
leak_obj.add_attribute('duplicate', value=p_duplicate, type='text')
@ -206,6 +204,7 @@ def misp_create_event(distribution, threat_level_id, analysis, info, l_tags, pub
print ("Template for type {} not found! Valid types are: {%s}".format(obj_name, valid_types))
r = pymisp.add_object(eventid, templateID, leak_obj)
if 'errors' in r:
print(r)
return False
else:
event_url = misp_event_url + eventid
@ -251,7 +250,7 @@ def hive_create_case(hive_tlp, threat_level, hive_description, hive_case_title,
if res.status_code != 201:
print('ko: {}/{}'.format(res.status_code, res.text))
r_serv_metadata.set('hive_cases:path', id)
r_serv_metadata.set('hive_cases:'+path, id)
return hive_case_url.replace('id_here', id)
else:
@ -286,7 +285,8 @@ def submit():
if ltags or ltagsgalaxies:
if not addTagsVerification(ltags, ltagsgalaxies):
return 'INVALID TAGS'
content = {'INVALID TAGS'}
return content, status.HTTP_400_BAD_REQUEST
# add submitted tags
if(ltags != ''):
@ -329,10 +329,11 @@ def submit():
UUID = UUID)
else:
print('wrong file type')
content = {'wrong file type'}
return content, status.HTTP_400_BAD_REQUEST
if paste_content != '':
elif paste_content != '':
if sys.getsizeof(paste_content) < 900000:
# get id
@ -348,9 +349,11 @@ def submit():
UUID = UUID)
else:
return 'size error'
content = {'size error'}
return content, status.HTTP_400_BAD_REQUEST
return 'submit'
content = {'submit aborded'}
return content, status.HTTP_400_BAD_REQUEST
return PasteSubmit_page()
@ -440,8 +443,8 @@ def create_misp_event():
if event != False:
return redirect(event)
else:
return 'error'
return 'error'
return 'error1'
return 'error0'
@PasteSubmit.route("/PasteSubmit/create_hive_case", methods=['POST'])
def create_hive_case():

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB