Skip to content

Commit

Permalink
Add error message in getstatus_scan response
Browse files Browse the repository at this point in the history
  • Loading branch information
[email protected] committed Jun 18, 2020
1 parent d2fdc1e commit 6c569bc
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion PatrowlEnginesUtils/PatrowlEngine.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,8 @@ def clean_scan(self, scan_id):

def getstatus_scan(self, scan_id):
"""Get the status of a scan identified by his 'id'."""

response = {}
if scan_id not in self.scans.keys():
raise PatrowlEngineExceptions(1002,"scan_id '{}' not found".format(scan_id))

Expand All @@ -196,7 +198,16 @@ def getstatus_scan(self, scan_id):
# update finished time if not already set
self.scans[scan_id]['finished_at'] = int(time.time() * 1000)

return jsonify({"status": self.scans[scan_id]['status']})
# if a reason is specified, replicate it in response
if 'reason' in self.scans[scan_id].keys():
response.update({'reason': self.scans[scan_id]['reason']})
elif 'details' in self.scans[scan_id].keys() and 'reason' in self.scans[scan_id]['details']:
response.update({'reason': self.scans[scan_id]['details']['reason'])

response.update({'status': self.scans[scan_id]['status'],
'finished_at': self.scans[scan_id]['finished_at']})

return jsonify(response)


def getstatus(self):
Expand Down

1 comment on commit 6c569bc

@agrandville
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

refer to Patrowl#3

Please sign in to comment.