Skip to content

Commit

Permalink
Fixes #332, checks if reanalization is disabled and if sample submiss…
Browse files Browse the repository at this point in the history
…ion was successful.
  • Loading branch information
3c7 committed Aug 14, 2018
1 parent 7bd33d7 commit 35738c3
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
16 changes: 14 additions & 2 deletions analyzers/VMRay/vmray.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@ class VMRayAnalyzer(Analyzer):
def __init__(self):
Analyzer.__init__(self)
self.url = self.get_param('config.url', None, 'No VMRay url given.').rstrip('/ ')
disable_reanalyze = self.get_param('config.disablereanalyze', False)
if disable_reanalyze == 'true' or disable_reanalyze:
self.disable_reanalyze = self.get_param('config.disablereanalyze', False)

# Check for string and boolean True
if self.disable_reanalyze == 'true' or self.disable_reanalyze:
reanalyze = False
else:
reanalyze = True
Expand All @@ -35,6 +37,16 @@ def run(self):
filename = self.get_param('filename')
submit_report = self.vmrc.submit_sample(filepath=filepath,
filename=filename)
# Ref: #332: check if job was submitted
if self.disable_reanalyze:
if len(submit_report['data']['errors']) > 0:
if submit_report['result'] == 'ok':
self.error('Sample was already submitted before and reanalization is disabled. Find it '
'<a href="{}">here</a>.'
.format(submit_report['data']['samples'][0]['sample_webif_url']))
else:
self.error('Error while submitting sample to VMRay: {}.'
.format([error_msg for error_msg in submit_report['data']['errors']]))
# Check for completion
while not self.vmrc.query_job_status(submissionid=submit_report['data']['submissions'][0]['submission_id']):
sleep(10)
Expand Down
2 changes: 1 addition & 1 deletion analyzers/VMRay/vmrayclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def get_sample(self, samplehash):
raise BadResponseError('Response from VMRay was not HTTP 200.'
' Responsecode: {}; Text: {}'.format(res.status_code, res.text))

def submit_sample(self, filepath, filename, tags=['JAMIE_Import', 'TheHive_Import']):
def submit_sample(self, filepath, filename, tags=['TheHive']):
"""
Uploads a new sample to VMRay api. Filename gets sent base64 encoded.
Expand Down

0 comments on commit 35738c3

Please sign in to comment.