From f6fd93bcb193f7041ab9abc68acd55fd4876dd81 Mon Sep 17 00:00:00 2001 From: Shreya Date: Fri, 31 Jul 2020 22:11:39 +0530 Subject: [PATCH 1/3] Set flask config 'JSON_SORT_KEYS' to false --- monkey/monkey_island/cc/app.py | 1 + 1 file changed, 1 insertion(+) diff --git a/monkey/monkey_island/cc/app.py b/monkey/monkey_island/cc/app.py index 6647d4b10..2047adf11 100644 --- a/monkey/monkey_island/cc/app.py +++ b/monkey/monkey_island/cc/app.py @@ -143,6 +143,7 @@ def init_api_resources(api): def init_app(mongo_url): app = Flask(__name__) + app.config['JSON_SORT_KEYS'] = False api = flask_restful.Api(app) api.representations = {'application/json': output_json} From b80e504400b824ff9f0d46a590d190befffa5765 Mon Sep 17 00:00:00 2001 From: Shreya Date: Fri, 31 Jul 2020 23:21:57 +0530 Subject: [PATCH 2/3] Shift the config variable change to the allocated function --- monkey/monkey_island/cc/app.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/monkey/monkey_island/cc/app.py b/monkey/monkey_island/cc/app.py index 2047adf11..c5b4d128f 100644 --- a/monkey/monkey_island/cc/app.py +++ b/monkey/monkey_island/cc/app.py @@ -78,6 +78,10 @@ def init_app_config(app, mongo_url): # deciding to reset credentials and then still logging in with the old JWT. app.config['JWT_SECRET_KEY'] = str(uuid.uuid4()) + # By default, Flask sorts keys of JSON objects alphabetically, which messes with the ATT&CK matrix in the + # configuration. See https://flask.palletsprojects.com/en/1.1.x/config/#JSON_SORT_KEYS. + app.config['JSON_SORT_KEYS'] = False + def init_app_services(app): init_jwt(app) @@ -143,7 +147,6 @@ def init_api_resources(api): def init_app(mongo_url): app = Flask(__name__) - app.config['JSON_SORT_KEYS'] = False api = flask_restful.Api(app) api.representations = {'application/json': output_json} From 698df755118aa9b6b1f08165c60b394e537e772d Mon Sep 17 00:00:00 2001 From: Shay Nehmad Date: Sat, 1 Aug 2020 18:10:49 +0300 Subject: [PATCH 3/3] See https://github.com/mongomock/mongomock/commit/cd034305d03534223db4b04d18252280fc29855e This is a breaking change for us, for now we'll stay with the old version until we take a deeper look into this --- monkey/monkey_island/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/monkey/monkey_island/requirements.txt b/monkey/monkey_island/requirements.txt index 88af6bad0..08049006b 100644 --- a/monkey/monkey_island/requirements.txt +++ b/monkey/monkey_island/requirements.txt @@ -11,7 +11,7 @@ flask>=1.1 ipaddress>=1.0.23 jsonschema==3.2.0 mongoengine>=0.20 -mongomock>=3.19 +mongomock==3.19.0 netifaces>=0.10.9 pycryptodome==3.9.8 pytest>=5.4