mirror of https://github.com/MISP/PyMISP
Fix upload function
parent
5ee23d46c0
commit
8a931a89f3
|
@ -2,7 +2,7 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
from pymisp import PyMISP
|
from pymisp import PyMISP
|
||||||
from keys import misp_url, misp_key,misp_verifycert
|
from keys import misp_url, misp_key, misp_verifycert
|
||||||
import argparse
|
import argparse
|
||||||
import os
|
import os
|
||||||
import glob
|
import glob
|
||||||
|
@ -12,8 +12,8 @@ def init(url, key):
|
||||||
return PyMISP(url, key, misp_verifycert, 'json')
|
return PyMISP(url, key, misp_verifycert, 'json')
|
||||||
|
|
||||||
|
|
||||||
def upload_files(m, eid, paths, distrib, ids, categ, info, analysis, threat):
|
def upload_files(m, eid, paths, distrib, ids, categ, comment, info, analysis, threat):
|
||||||
out = m.upload_samplelist(paths, eid, distrib, ids, categ, info, analysis, threat)
|
out = m.upload_samplelist(paths, eid, distrib, ids, categ, comment, info, analysis, threat)
|
||||||
print(out)
|
print(out)
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
@ -26,6 +26,7 @@ if __name__ == '__main__':
|
||||||
parser.add_argument("-i", "--info", help="Used to populate the event info field if no event ID supplied.")
|
parser.add_argument("-i", "--info", help="Used to populate the event info field if no event ID supplied.")
|
||||||
parser.add_argument("-a", "--analysis", type=int, help="The analysis level of the newly created event, if applicatble. [0-2]")
|
parser.add_argument("-a", "--analysis", type=int, help="The analysis level of the newly created event, if applicatble. [0-2]")
|
||||||
parser.add_argument("-t", "--threat", type=int, help="The threat level ID of the newly created event, if applicatble. [1-4]")
|
parser.add_argument("-t", "--threat", type=int, help="The threat level ID of the newly created event, if applicatble. [1-4]")
|
||||||
|
parser.add_argument("-co", "--comment", type=str, help="Comment for the uploaded file(s).")
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
misp = init(misp_url, misp_key)
|
misp = init(misp_url, misp_key)
|
||||||
|
@ -39,4 +40,4 @@ if __name__ == '__main__':
|
||||||
print('invalid file')
|
print('invalid file')
|
||||||
exit(0)
|
exit(0)
|
||||||
|
|
||||||
upload_files(misp, args.event, files, args.distrib, args.ids, args.categ, args.info, args.analysis, args.threat)
|
upload_files(misp, args.event, files, args.distrib, args.ids, args.categ, args.comment, args.info, args.analysis, args.threat)
|
||||||
|
|
|
@ -668,10 +668,10 @@ class PyMISP(object):
|
||||||
return self._upload_sample(to_post)
|
return self._upload_sample(to_post)
|
||||||
|
|
||||||
def upload_samplelist(self, filepaths, event_id, distribution=None,
|
def upload_samplelist(self, filepaths, event_id, distribution=None,
|
||||||
to_ids=True, category=None, info=None,
|
to_ids=True, category=None, comment=None, info=None,
|
||||||
analysis=None, threat_level_id=None):
|
analysis=None, threat_level_id=None):
|
||||||
to_post = self._prepare_upload(event_id, distribution, to_ids, category,
|
to_post = self._prepare_upload(event_id, distribution, to_ids, category,
|
||||||
info, analysis, threat_level_id)
|
comment, info, analysis, threat_level_id)
|
||||||
files = []
|
files = []
|
||||||
for path in filepaths:
|
for path in filepaths:
|
||||||
if not os.path.isfile(path):
|
if not os.path.isfile(path):
|
||||||
|
|
Loading…
Reference in New Issue