Fix last commit

pull/2/merge
Raphaël Vinot 2015-08-06 09:49:44 +02:00
parent dd3591f87c
commit 208091dc47
2 changed files with 7 additions and 5 deletions

View File

@ -14,7 +14,7 @@ def init(url, key):
def upload_files(m, eid, paths, distrib, ids, categ, info, analysis, threat):
out = m.upload_sample(eid, paths, distrib, ids, categ, info, analysis, threat)
out = m.upload_samplelist(paths, eid, distrib, ids, categ, info, analysis, threat)
if out.status_code == 200:
print("Files uploaded sucessfully")
else:
@ -41,5 +41,8 @@ if __name__ == '__main__':
files = [args.upload]
elif os.path.isdir(args.upload):
files = [f for f in glob.iglob(os.path.join(args.upload + '*'))]
else:
print('invalid file')
exit(0)
upload_files(misp, args.event, files, args.distrib, args.ids, args.categ, args.info, args.analysis, args.threat)

View File

@ -147,12 +147,11 @@ class PyMISP(object):
def prepare_attribute(self, event_id, distribution, to_ids, category, info,
analysis, threat_level_id):
to_post = {'request': {'files': []}}
to_post = {'request': {}}
if not isinstance(event_id, int):
# New event
postcontent = self._create_event(distribution, threat_level_id,
analysis, info)
to_post['request'].update(postcontent)
to_post['request'].update(self._create_event(distribution, threat_level_id,
analysis, info))
else:
to_post['request'].update({'event_id': int(event_id)})