Skip to content

Commit

Permalink
Merge e3bd073 into ba02c6c
Browse files Browse the repository at this point in the history
  • Loading branch information
DragonDev1906 committed Sep 28, 2018
2 parents ba02c6c + e3bd073 commit c006bfb
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions pymisp/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -847,7 +847,7 @@ def add_other_text(self, event, reference, category='Other', to_ids=False, comme
# ##################################################

def _prepare_upload(self, event_id, distribution, to_ids, category, comment, info,
analysis, threat_level_id):
analysis, threat_level_id, advanced_extraction):
"""Helper to prepare a sample to upload"""
to_post = {'request': {}}

Expand Down Expand Up @@ -877,6 +877,7 @@ def _prepare_upload(self, event_id, distribution, to_ids, category, comment, inf
to_post['request']['category'] = category

to_post['request']['comment'] = comment
to_post['request']['advanced'] = 1 if advanced_extraction else 0
return to_post, event_id

def _encode_file_to_upload(self, filepath_or_bytes):
Expand All @@ -893,19 +894,21 @@ def _encode_file_to_upload(self, filepath_or_bytes):

def upload_sample(self, filename, filepath_or_bytes, event_id, distribution=None,
to_ids=True, category=None, comment=None, info=None,
analysis=None, threat_level_id=None):
analysis=None, threat_level_id=None, advanced_extraction=False):
"""Upload a sample"""
to_post, event_id = self._prepare_upload(event_id, distribution, to_ids, category,
comment, info, analysis, threat_level_id)
comment, info, analysis, threat_level_id,
advanced_extraction)
to_post['request']['files'] = [{'filename': filename, 'data': self._encode_file_to_upload(filepath_or_bytes)}]
return self._upload_sample(to_post, event_id)

def upload_samplelist(self, filepaths, event_id, distribution=None,
to_ids=True, category=None, comment=None, info=None,
analysis=None, threat_level_id=None):
analysis=None, threat_level_id=None, advanced_extraction=False):
"""Upload a list of samples"""
to_post, event_id = self._prepare_upload(event_id, distribution, to_ids, category,
comment, info, analysis, threat_level_id)
comment, info, analysis, threat_level_id,
advanced_extraction)
files = []
for path in filepaths:
if not os.path.isfile(path):
Expand Down

0 comments on commit c006bfb

Please sign in to comment.