Skip to content

Commit

Permalink
Merge pull request #139 from agrandville/APIVoid
Browse files Browse the repository at this point in the history
Add APIVOID engine
  • Loading branch information
MaKyOtOx authored Jun 25, 2020
2 parents 8ed8bb8 + afc1745 commit f4ccc51
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 4 deletions.
22 changes: 18 additions & 4 deletions engines/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,9 @@ def startscan_task(self, params):
response_reason = 'Unknown'
if 'details' in json.loads(resp.text) and 'reason' in json.loads(resp.text)['details']:
response_reason = json.loads(resp.text)['details']['reason']
elif 'reason' in json.loads(resp.text):
response_reason = json.loads(resp.text)['reason']

Event.objects.create(message="[EngineTasks/startscan_task/{}] DuringScan - something goes wrong (response_status_code={}, response_status={}, response_details={}). Task aborted.".format(self.request.id, resp.status_code, json.loads(resp.text)['status'], response_reason),
description=str(resp.text), type="ERROR", severity="ERROR", scan=scan)
return False
Expand Down Expand Up @@ -439,9 +442,20 @@ def startscan_task(self, params):
scan.status = "error"
scan.finished_at = timezone.now()
scan.save()
Event.objects.create(message="[EngineTasks/startscan_task/{}] AfterScan - something goes wrong in 'getfindings' call (request_status_code={}). Task aborted.".format(self.request.id, resp.status_code),
type="ERROR", severity="ERROR", scan=scan, description="{}".format(resp.text))
response_reason = "Undefined"

if 'details' in json.loads(resp.text) and 'reason' in json.loads(resp.text)['details']:
response_reason = json.loads(resp.text)['details']['reason']
elif 'reason' in json.loads(resp.text):
response_reason = json.loads(resp.text)['reason']

Event.objects.create(message="[EngineTasks/startscan_task/{}] AfterScan - something goes wrong"
" in 'getfindings' call (response_status_code={}, response_status={}, "
"response_details={}). Task aborted.".format(self.request.id,
resp.status_code,json.loads(resp.text)['status'], response_reason),
type="ERROR", severity="ERROR", scan=scan, description="{}".format(resp.text))
return False

except Exception as e:
scan.status = "error"
scan.finished_at = timezone.now()
Expand Down Expand Up @@ -580,7 +594,7 @@ def start_periodic_scan_task(self, params):
retries -= 1

if retries == 0:
print("ERROR: start_periodicscan_task/beforescan - max_retries ({}) reached.".format(retries))
print("ERROR: start_periodicscan_task/beforescan - max_retries ({}) reached.".format(NB_MAX_RETRIES))
return False

# -2- call the engine REST API /startscan
Expand Down Expand Up @@ -619,7 +633,7 @@ def start_periodic_scan_task(self, params):
print("status: {}".format(scan_status))

if retries == 0:
print("ERROR: startscan_task/scaninprogress - max_retries ({}) reached.".format(retries))
print("ERROR: startscan_task/scaninprogress - max_retries ({}) reached.".format(NB_MAX_RETRIES))
return False

# Todo: change to wait the report becomes available
Expand Down
10 changes: 10 additions & 0 deletions var/data/engines.Engine.json
Original file line number Diff line number Diff line change
Expand Up @@ -208,4 +208,14 @@
"created_at": "2020-03-26T15:53:10.644Z",
"updated_at": "2020-03-26T15:53:10.644Z"
}
}, {
"model": "engines.engine",
"pk": 22,
"fields": {
"name": "APIVOID",
"description": "Reputation Scanner",
"allowed_asset_types": "[u'domain']",
"created_at": "2020-06-16T00:00:00.000Z",
"updated_at": "2020-06-16T00:00:00.000Z"
}
}]

0 comments on commit f4ccc51

Please sign in to comment.