diff --git a/monkey/monkey_island/cc/models/zero_trust/scoutsuite_data_json.py b/monkey/monkey_island/cc/models/zero_trust/scoutsuite_data_json.py index 4b493e878..9dbf7855a 100644 --- a/monkey/monkey_island/cc/models/zero_trust/scoutsuite_data_json.py +++ b/monkey/monkey_island/cc/models/zero_trust/scoutsuite_data_json.py @@ -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() diff --git a/monkey/monkey_island/cc/models/zero_trust/scoutsuite_rule.py b/monkey/monkey_island/cc/models/zero_trust/scoutsuite_rule.py index 316a5402e..263cda8fd 100644 --- a/monkey/monkey_island/cc/models/zero_trust/scoutsuite_rule.py +++ b/monkey/monkey_island/cc/models/zero_trust/scoutsuite_rule.py @@ -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) diff --git a/monkey/monkey_island/cc/resources/reporting/report.py b/monkey/monkey_island/cc/resources/reporting/report.py index 5273ca810..b1e38009e 100644 --- a/monkey/monkey_island/cc/resources/reporting/report.py +++ b/monkey/monkey_island/cc/resources/reporting/report.py @@ -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)