mirror of
https://github.com/valitydev/Cortex-Analyzers.git
synced 2024-11-07 01:25:21 +00:00
Fixes #332, checks if reanalization is disabled and if sample submission was successful.
This commit is contained in:
parent
7bd33d7545
commit
35738c3a0e
@ -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
|
||||
@ -35,6 +37,16 @@ class VMRayAnalyzer(Analyzer):
|
||||
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)
|
||||
|
@ -92,7 +92,7 @@ class VMRayClient:
|
||||
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.
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user