From c25ea0edf83d27b14e35dd7fdf5cbb3e8d9347ed Mon Sep 17 00:00:00 2001 From: VakarisZ Date: Thu, 3 Jun 2021 13:30:27 +0300 Subject: [PATCH] Fixed bugs in config import backend (related to json parsing and stringifying) and front end (unsafe import warning overlay) --- monkey/monkey_island/cc/resources/configuration_import.py | 2 +- .../configuration-components/ImportConfigModal.tsx | 6 +++--- .../configuration-components/ImportConfigModal.scss | 8 ++++++++ 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/monkey/monkey_island/cc/resources/configuration_import.py b/monkey/monkey_island/cc/resources/configuration_import.py index 10a33263a..549ff1a93 100644 --- a/monkey/monkey_island/cc/resources/configuration_import.py +++ b/monkey/monkey_island/cc/resources/configuration_import.py @@ -48,7 +48,7 @@ class ConfigurationImport(flask_restful.Resource): return ResponseContents().form_response() else: return ResponseContents( - config=config, + config=json.dumps(config), config_schema=ConfigService.get_config_schema(), import_status="unsafe_options_verification_required", status_code=403, diff --git a/monkey/monkey_island/cc/ui/src/components/configuration-components/ImportConfigModal.tsx b/monkey/monkey_island/cc/ui/src/components/configuration-components/ImportConfigModal.tsx index 3f355e917..c1e12ae86 100644 --- a/monkey/monkey_island/cc/ui/src/components/configuration-components/ImportConfigModal.tsx +++ b/monkey/monkey_island/cc/ui/src/components/configuration-components/ImportConfigModal.tsx @@ -62,9 +62,9 @@ const ConfigImportModal = (props: Props) => { setUploadStatus(UploadStatuses.error); setErrorMessage(res['message']); } else if (res['import_status'] === 'unsafe_options_verification_required') { - if (isUnsafeOptionSelected(res['config_schema'], res['config'])) { + if (isUnsafeOptionSelected(res['config_schema'], JSON.parse(res['config']))) { setShowUnsafeOptionsConfirmation(true); - setCandidateConfig(JSON.stringify(res['config'])); + setCandidateConfig(res['config']); } else { setUnsafeOptionsVerified(true); setConfigContents(res['config']); @@ -133,8 +133,8 @@ const ConfigImportModal = (props: Props) => { - {showVerificationDialog()}
+ {showVerificationDialog()}