From d67e84a6a758c3b980c4e5dfba8c385b57087158 Mon Sep 17 00:00:00 2001 From: Shreya Date: Tue, 1 Jun 2021 12:52:37 +0530 Subject: [PATCH] Make sure (1) config is updated before exporting; (2) plaintext config is exported correctly --- .../configuration-components/ExportConfigModal.tsx | 3 ++- .../cc/ui/src/components/pages/ConfigurePage.js | 9 ++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/monkey/monkey_island/cc/ui/src/components/configuration-components/ExportConfigModal.tsx b/monkey/monkey_island/cc/ui/src/components/configuration-components/ExportConfigModal.tsx index c12208170..a6dc47c2d 100644 --- a/monkey/monkey_island/cc/ui/src/components/configuration-components/ExportConfigModal.tsx +++ b/monkey/monkey_island/cc/ui/src/components/configuration-components/ExportConfigModal.tsx @@ -38,7 +38,8 @@ const ConfigExportModal = (props: Props) => { .then(res => { let configToExport = res['to_export']; if (res['is_plaintext'] === true) { - const configAsBinary = new Blob([configToExport], {type: 'text/plain;charset=utf-8'}); + const configAsBinary = new Blob([JSON.stringify(configToExport, null, 2)], + {type: 'text/plain;charset=utf-8'}); FileSaver.saveAs(configAsBinary, 'monkey.conf'); } else { diff --git a/monkey/monkey_island/cc/ui/src/components/pages/ConfigurePage.js b/monkey/monkey_island/cc/ui/src/components/pages/ConfigurePage.js index 251aa12fa..0aae3f356 100644 --- a/monkey/monkey_island/cc/ui/src/components/pages/ConfigurePage.js +++ b/monkey/monkey_island/cc/ui/src/components/pages/ConfigurePage.js @@ -369,6 +369,11 @@ class ConfigurePageComponent extends AuthComponent { this.authFetch(apiEndpoint, request_options); } + exportConfig = () => { + this.updateConfigSection(); + this.setState({showConfigExportModal: true}); + }; + sendConfig() { return ( this.authFetch('/api/configuration/island', @@ -500,9 +505,7 @@ class ConfigurePageComponent extends AuthComponent { Import config