Fixed scoutsuite backend bugs

This commit is contained in:
VakarisZ 2020-09-23 10:26:35 +03:00
parent dc295d4a60
commit 3b0a8e87c2
3 changed files with 6 additions and 5 deletions

View File

@ -12,8 +12,9 @@ class ScoutSuiteDataJson(Document):
# LOGIC
@staticmethod
def add_scoutsuite_data(scoutsuite_data: str) -> None:
current_data = ScoutSuiteDataJson.objects()
if not current_data:
try:
current_data = ScoutSuiteDataJson.objects()[0]
except IndexError:
current_data = ScoutSuiteDataJson()
current_data.scoutsuite_data = scoutsuite_data
current_data.save()

View File

@ -1,5 +1,5 @@
from mongoengine import StringField, EmbeddedDocument, ListField, \
IntField
IntField, DynamicField
from monkey_island.cc.services.zero_trust.scoutsuite.consts import rule_consts
@ -22,5 +22,5 @@ class ScoutSuiteRule(EmbeddedDocument):
service = StringField(required=True)
rationale = StringField(required=True)
remediation = StringField(required=False)
compliance = StringField(required=False)
compliance = DynamicField(required=False)
references = ListField(required=False)

View File

@ -43,7 +43,7 @@ class Report(flask_restful.Resource):
try:
data = ScoutSuiteDataJson.objects.get().scoutsuite_data
except Exception:
data = {}
data = "{}"
return Response(data, mimetype='application/json')
flask_restful.abort(http.client.NOT_FOUND)