From 510b001c2ad0b0b70e477d9f15d18e485d37c1d3 Mon Sep 17 00:00:00 2001 From: Mike Salvatore Date: Thu, 25 Feb 2021 11:24:39 -0500 Subject: [PATCH 01/21] ui: add a modal dialog that asks users to confirm unsafe options --- .../ui/src/components/pages/ConfigurePage.js | 59 ++++++++++++++++++- 1 file changed, 58 insertions(+), 1 deletion(-) 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 426e66c0a..8c45f0747 100644 --- a/monkey/monkey_island/cc/ui/src/components/pages/ConfigurePage.js +++ b/monkey/monkey_island/cc/ui/src/components/pages/ConfigurePage.js @@ -34,7 +34,9 @@ class ConfigurePageComponent extends AuthComponent { lastAction: 'none', sections: [], selectedSection: 'attack', - showAttackAlert: false + showAttackAlert: false, + showUnsafeOptionsConfirmation: false, + unsafeOptionsConfirmed: false }; } @@ -84,13 +86,28 @@ class ConfigurePageComponent extends AuthComponent { }; onSubmit = () => { + if (!this.canSafelySubmitConfig()) { + this.setState({showUnsafeOptionsConfirmation: true}); + return; + } + if (this.state.selectedSection === 'attack') { this.matrixSubmit() } else { this.configSubmit() } + + this.setState({unsafeOptionsConfirmed: false}) }; + canSafelySubmitConfig() { + return !this.unsafeOptionsSelected() || this.state.unsafeOptionsConfirmed + } + + unsafeOptionsSelected() { + return true; + } + matrixSubmit = () => { // Submit attack matrix this.authFetch(ATTACK_URL, @@ -201,6 +218,45 @@ class ConfigurePageComponent extends AuthComponent { ) }; + renderUnsafeOptionsConfirmationModal = () => { + return ( + + +

+
Warning
+

+

+ You have selected some options which are not safe for all environments. + These options could cause some systems to become unstable or malfunction. + Are you sure you want to use the selected settings? +

+
+ + +
+
+
+ ) + } + userChangedConfig() { if (JSON.stringify(this.state.configuration) === JSON.stringify(this.initialConfig)) { if (Object.keys(this.currentFormData).length === 0 || @@ -410,6 +466,7 @@ class ConfigurePageComponent extends AuthComponent { lg={{offset: 3, span: 8}} xl={{offset: 2, span: 8}} className={'main'}> {this.renderAttackAlertModal()} + {this.renderUnsafeOptionsConfirmationModal()}

Monkey Configuration

{this.renderNav()} {content} From 6813262b30ad39295420bd89b348a7e38a37e838 Mon Sep 17 00:00:00 2001 From: Mike Salvatore Date: Thu, 25 Feb 2021 13:37:41 -0500 Subject: [PATCH 02/21] ui: check PBA, exploiter, and system info safety on submit --- .../ui/src/components/pages/ConfigurePage.js | 55 ++++++++++++++++--- 1 file changed, 46 insertions(+), 9 deletions(-) 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 8c45f0747..b0990fc8c 100644 --- a/monkey/monkey_island/cc/ui/src/components/pages/ConfigurePage.js +++ b/monkey/monkey_island/cc/ui/src/components/pages/ConfigurePage.js @@ -86,26 +86,55 @@ class ConfigurePageComponent extends AuthComponent { }; onSubmit = () => { - if (!this.canSafelySubmitConfig()) { - this.setState({showUnsafeOptionsConfirmation: true}); - return; - } - if (this.state.selectedSection === 'attack') { this.matrixSubmit() } else { this.configSubmit() } - - this.setState({unsafeOptionsConfirmed: false}) }; canSafelySubmitConfig() { - return !this.unsafeOptionsSelected() || this.state.unsafeOptionsConfirmed + return !this.unsafeOptionsSelected() || this.state.unsafeOptionsConfirmed; } unsafeOptionsSelected() { - return true; + return (this.unsafeExploiterSelected() + || this.unsafePostBreachActionSelected() + || this.unsafeSystemInfoCollectorSelected()); + } + + unsafeExploiterSelected() { + return this.unsafeItemSelected( + this.state.schema.definitions.exploiter_classes.anyOf, + this.state.configuration.basic.exploiters.exploiter_classes + ); + } + + unsafePostBreachActionSelected() { + return this.unsafeItemSelected( + this.state.schema.definitions.post_breach_actions.anyOf, + this.state.configuration.monkey.post_breach.post_breach_actions + ); + } + + unsafeSystemInfoCollectorSelected() { + return this.unsafeItemSelected( + this.state.schema.definitions.system_info_collector_classes.anyOf, + this.state.configuration.monkey.system_info.system_info_collector_classes + ); + } + + unsafeItemSelected(options, selectedOptions) { + let item_safety = new Map(); + options.forEach(i => item_safety[i.enum[0]] = i.safe); + + for (let selected of selectedOptions) { + if (!item_safety[selected]) { + return true; + } + } + + return false; } matrixSubmit = () => { @@ -136,6 +165,12 @@ class ConfigurePageComponent extends AuthComponent { configSubmit = () => { // Submit monkey configuration this.updateConfigSection(); + + if (!this.canSafelySubmitConfig()) { + this.setState({showUnsafeOptionsConfirmation: true}); + return; + } + this.sendConfig() .then(res => res.json()) .then(res => { @@ -150,6 +185,8 @@ class ConfigurePageComponent extends AuthComponent { console.log('Bad configuration: ' + error.toString()); this.setState({lastAction: 'invalid_configuration'}); }); + + this.setState({unsafeOptionsConfirmed: false}) }; // Alters attack configuration when user toggles technique From d160787851bf90ab62938fb9c30b041cf96b5333 Mon Sep 17 00:00:00 2001 From: Mike Salvatore Date: Thu, 25 Feb 2021 15:39:32 -0500 Subject: [PATCH 03/21] ui: extract renderUnsafeOptionsConfirmationModal() into a component --- .../UnsafeOptionsConfirmationModal.js | 37 ++++++++++++ .../ui/src/components/pages/ConfigurePage.js | 57 ++++++------------- 2 files changed, 54 insertions(+), 40 deletions(-) create mode 100644 monkey/monkey_island/cc/ui/src/components/configuration-components/UnsafeOptionsConfirmationModal.js diff --git a/monkey/monkey_island/cc/ui/src/components/configuration-components/UnsafeOptionsConfirmationModal.js b/monkey/monkey_island/cc/ui/src/components/configuration-components/UnsafeOptionsConfirmationModal.js new file mode 100644 index 000000000..1fbf8b0b3 --- /dev/null +++ b/monkey/monkey_island/cc/ui/src/components/configuration-components/UnsafeOptionsConfirmationModal.js @@ -0,0 +1,37 @@ +import React from 'react'; +import {Modal, Button} from 'react-bootstrap'; + +function UnsafeOptionsConfirmationModal(props) { + return ( + + +

+
Warning
+

+

+ You have selected some options which are not safe for all environments. + These options could cause some systems to become unstable or malfunction. + Are you sure you want to use the selected settings? +

+
+ + +
+
+
+ ) +} + +export default UnsafeOptionsConfirmationModal; 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 b0990fc8c..8345ca588 100644 --- a/monkey/monkey_island/cc/ui/src/components/pages/ConfigurePage.js +++ b/monkey/monkey_island/cc/ui/src/components/pages/ConfigurePage.js @@ -11,6 +11,7 @@ import {faExclamationCircle} from '@fortawesome/free-solid-svg-icons/faExclamati import {formValidationFormats} from '../configuration-components/ValidationFormats'; import transformErrors from '../configuration-components/ValidationErrorMessages'; import InternalConfig from '../configuration-components/InternalConfig'; +import UnsafeOptionsConfirmationModal from '../configuration-components/UnsafeOptionsConfirmationModal.js'; const ATTACK_URL = '/api/attack'; const CONFIG_URL = '/api/configuration/island'; @@ -76,6 +77,17 @@ class ConfigurePageComponent extends AuthComponent { }); }; + onUnsafeConfirmationCancelClick = () => { + this.setState({showUnsafeOptionsConfirmation: false}) + } + + onUnsafeConfirmationContinueClick = () => { + this.setState( + {unsafeOptionsConfirmed: true, showUnsafeOptionsConfirmation: false}, + () => {this.onSubmit()} + ); + } + updateConfig = () => { this.authFetch(CONFIG_URL) .then(res => res.json()) @@ -255,45 +267,6 @@ class ConfigurePageComponent extends AuthComponent { ) }; - renderUnsafeOptionsConfirmationModal = () => { - return ( - - -

-
Warning
-

-

- You have selected some options which are not safe for all environments. - These options could cause some systems to become unstable or malfunction. - Are you sure you want to use the selected settings? -

-
- - -
-
-
- ) - } - userChangedConfig() { if (JSON.stringify(this.state.configuration) === JSON.stringify(this.initialConfig)) { if (Object.keys(this.currentFormData).length === 0 || @@ -503,7 +476,11 @@ class ConfigurePageComponent extends AuthComponent { lg={{offset: 3, span: 8}} xl={{offset: 2, span: 8}} className={'main'}> {this.renderAttackAlertModal()} - {this.renderUnsafeOptionsConfirmationModal()} +

Monkey Configuration

{this.renderNav()} {content} From 8fd1582909b828109915d467cbbf938a95e1b12e Mon Sep 17 00:00:00 2001 From: Mike Salvatore Date: Thu, 25 Feb 2021 19:19:36 -0500 Subject: [PATCH 04/21] ui: display modal dialog when unsafe config is imported --- .../ui/src/components/pages/ConfigurePage.js | 53 +++++++++++++------ 1 file changed, 37 insertions(+), 16 deletions(-) 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 8345ca588..dc054ffce 100644 --- a/monkey/monkey_island/cc/ui/src/components/pages/ConfigurePage.js +++ b/monkey/monkey_island/cc/ui/src/components/pages/ConfigurePage.js @@ -84,7 +84,13 @@ class ConfigurePageComponent extends AuthComponent { onUnsafeConfirmationContinueClick = () => { this.setState( {unsafeOptionsConfirmed: true, showUnsafeOptionsConfirmation: false}, - () => {this.onSubmit()} + () => { + if (this.state.lastAction == 'submit_attempt') { + this.onSubmit(); + } else if (this.state.lastAction == 'import_attempt') { + this.setConfigFromCandidateJson(this.state.candidateConfigJson); + } + } ); } @@ -105,34 +111,34 @@ class ConfigurePageComponent extends AuthComponent { } }; - canSafelySubmitConfig() { - return !this.unsafeOptionsSelected() || this.state.unsafeOptionsConfirmed; + canSafelySubmitConfig(config) { + return !this.unsafeOptionsSelected(config) || this.state.unsafeOptionsConfirmed; } - unsafeOptionsSelected() { - return (this.unsafeExploiterSelected() - || this.unsafePostBreachActionSelected() - || this.unsafeSystemInfoCollectorSelected()); + unsafeOptionsSelected(config) { + return (this.unsafeExploiterSelected(config) + || this.unsafePostBreachActionSelected(config) + || this.unsafeSystemInfoCollectorSelected(config)); } - unsafeExploiterSelected() { + unsafeExploiterSelected(config) { return this.unsafeItemSelected( this.state.schema.definitions.exploiter_classes.anyOf, - this.state.configuration.basic.exploiters.exploiter_classes + config.basic.exploiters.exploiter_classes ); } - unsafePostBreachActionSelected() { + unsafePostBreachActionSelected(config) { return this.unsafeItemSelected( this.state.schema.definitions.post_breach_actions.anyOf, - this.state.configuration.monkey.post_breach.post_breach_actions + config.monkey.post_breach.post_breach_actions ); } - unsafeSystemInfoCollectorSelected() { + unsafeSystemInfoCollectorSelected(config) { return this.unsafeItemSelected( this.state.schema.definitions.system_info_collector_classes.anyOf, - this.state.configuration.monkey.system_info.system_info_collector_classes + config.monkey.system_info.system_info_collector_classes ); } @@ -176,9 +182,10 @@ class ConfigurePageComponent extends AuthComponent { configSubmit = () => { // Submit monkey configuration + this.setState({lastAction: 'submit_attempt'}); this.updateConfigSection(); - if (!this.canSafelySubmitConfig()) { + if (!this.canSafelySubmitConfig(this.state.configuration)) { this.setState({showUnsafeOptionsConfirmation: true}); return; } @@ -341,18 +348,32 @@ class ConfigurePageComponent extends AuthComponent { } setConfigOnImport = (event) => { + this.setConfigFromCandidateJson(event.target.result); + } + + setConfigFromCandidateJson(newConfigCandidateJson){ try { + this.setState({lastAction: 'import_attempt', candidateConfigJson: newConfigCandidateJson}) + let newConfig = JSON.parse(newConfigCandidateJson); + + if (!this.canSafelySubmitConfig(newConfig)) { + this.setState({showUnsafeOptionsConfirmation: true}); + return; + } + this.setState({ - configuration: JSON.parse(event.target.result), + configuration: newConfig, lastAction: 'import_success' }, () => { this.sendConfig(); - this.setInitialConfig(JSON.parse(event.target.result)) + this.setInitialConfig(newConfig) }); this.currentFormData = {}; } catch (SyntaxError) { this.setState({lastAction: 'import_failure'}); } + + this.setState({unsafeOptionsConfirmed: false}) }; exportConfig = () => { From ff28509d0d93719577ec90acfc4863e0d0daef1a Mon Sep 17 00:00:00 2001 From: Mike Salvatore Date: Thu, 25 Feb 2021 19:41:36 -0500 Subject: [PATCH 05/21] ui: fix race in unsafe confirmation modal dialog --- .../ui/src/components/pages/ConfigurePage.js | 22 +++++++++++++------ 1 file changed, 15 insertions(+), 7 deletions(-) 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 dc054ffce..53dcdf27c 100644 --- a/monkey/monkey_island/cc/ui/src/components/pages/ConfigurePage.js +++ b/monkey/monkey_island/cc/ui/src/components/pages/ConfigurePage.js @@ -86,9 +86,9 @@ class ConfigurePageComponent extends AuthComponent { {unsafeOptionsConfirmed: true, showUnsafeOptionsConfirmation: false}, () => { if (this.state.lastAction == 'submit_attempt') { - this.onSubmit(); + this.attemptConfigSubmit(); } else if (this.state.lastAction == 'import_attempt') { - this.setConfigFromCandidateJson(this.state.candidateConfigJson); + this.attemptSetConfigFromCandidateJson(this.state.candidateConfigJson); } } ); @@ -107,7 +107,7 @@ class ConfigurePageComponent extends AuthComponent { if (this.state.selectedSection === 'attack') { this.matrixSubmit() } else { - this.configSubmit() + this.attemptConfigSubmit() } }; @@ -180,11 +180,13 @@ class ConfigurePageComponent extends AuthComponent { }); }; - configSubmit = () => { - // Submit monkey configuration - this.setState({lastAction: 'submit_attempt'}); + attemptConfigSubmit() { this.updateConfigSection(); + this.setState({lastAction: 'submit_attempt'}, this.configSubmit()); + } + configSubmit() { + // Submit monkey configuration if (!this.canSafelySubmitConfig(this.state.configuration)) { this.setState({showUnsafeOptionsConfirmation: true}); return; @@ -348,7 +350,13 @@ class ConfigurePageComponent extends AuthComponent { } setConfigOnImport = (event) => { - this.setConfigFromCandidateJson(event.target.result); + this.attemptSetConfigFromCandidateJson(event.target.result); + } + + attemptSetConfigFromCandidateJson(newConfigCandidateJson){ + this.setState({lastAction: 'import_attempt', candidateConfigJson: newConfigCandidateJson}, + this.setConfigFromCandidateJson(newConfigCandidateJson) + ); } setConfigFromCandidateJson(newConfigCandidateJson){ From 8f32c489641e6358cb90cf4341e69fcede6fca79 Mon Sep 17 00:00:00 2001 From: Mike Salvatore Date: Thu, 25 Feb 2021 19:47:21 -0500 Subject: [PATCH 06/21] ui: make unsafeItemSelected() a pure function --- .../ui/src/components/pages/ConfigurePage.js | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) 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 53dcdf27c..c380c217b 100644 --- a/monkey/monkey_island/cc/ui/src/components/pages/ConfigurePage.js +++ b/monkey/monkey_island/cc/ui/src/components/pages/ConfigurePage.js @@ -18,6 +18,19 @@ const CONFIG_URL = '/api/configuration/island'; export const API_PBA_LINUX = '/api/fileUpload/PBAlinux'; export const API_PBA_WINDOWS = '/api/fileUpload/PBAwindows'; +function unsafeItemSelected(options, selectedOptions) { + let item_safety = new Map(); + options.forEach(i => item_safety[i.enum[0]] = i.safe); + + for (let selected of selectedOptions) { + if (!item_safety[selected]) { + return true; + } + } + + return false; +} + class ConfigurePageComponent extends AuthComponent { constructor(props) { @@ -122,39 +135,26 @@ class ConfigurePageComponent extends AuthComponent { } unsafeExploiterSelected(config) { - return this.unsafeItemSelected( + return unsafeItemSelected( this.state.schema.definitions.exploiter_classes.anyOf, config.basic.exploiters.exploiter_classes ); } unsafePostBreachActionSelected(config) { - return this.unsafeItemSelected( + return unsafeItemSelected( this.state.schema.definitions.post_breach_actions.anyOf, config.monkey.post_breach.post_breach_actions ); } unsafeSystemInfoCollectorSelected(config) { - return this.unsafeItemSelected( + return unsafeItemSelected( this.state.schema.definitions.system_info_collector_classes.anyOf, config.monkey.system_info.system_info_collector_classes ); } - unsafeItemSelected(options, selectedOptions) { - let item_safety = new Map(); - options.forEach(i => item_safety[i.enum[0]] = i.safe); - - for (let selected of selectedOptions) { - if (!item_safety[selected]) { - return true; - } - } - - return false; - } - matrixSubmit = () => { // Submit attack matrix this.authFetch(ATTACK_URL, From f82d4a1b97cd49b5ff464e7c08383a0c1b594f25 Mon Sep 17 00:00:00 2001 From: Mike Salvatore Date: Thu, 25 Feb 2021 19:54:32 -0500 Subject: [PATCH 07/21] ui: fix capitalization of "Import config" button for consistency --- .../monkey_island/cc/ui/src/components/pages/ConfigurePage.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 c380c217b..717f4b7dd 100644 --- a/monkey/monkey_island/cc/ui/src/components/pages/ConfigurePage.js +++ b/monkey/monkey_island/cc/ui/src/components/pages/ConfigurePage.js @@ -524,7 +524,7 @@ class ConfigurePageComponent extends AuthComponent {
From 88e2ccb30a330fd50b8baf2da3daa9d8e7355b48 Mon Sep 17 00:00:00 2001 From: Mike Salvatore Date: Thu, 25 Feb 2021 20:02:33 -0500 Subject: [PATCH 08/21] ui: pass callback, not return value, to setState() --- .../monkey_island/cc/ui/src/components/pages/ConfigurePage.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 717f4b7dd..015b3ffbb 100644 --- a/monkey/monkey_island/cc/ui/src/components/pages/ConfigurePage.js +++ b/monkey/monkey_island/cc/ui/src/components/pages/ConfigurePage.js @@ -182,7 +182,7 @@ class ConfigurePageComponent extends AuthComponent { attemptConfigSubmit() { this.updateConfigSection(); - this.setState({lastAction: 'submit_attempt'}, this.configSubmit()); + this.setState({lastAction: 'submit_attempt'}, this.configSubmit); } configSubmit() { From 68e835433a9fa63e21c414db800270308181d2c3 Mon Sep 17 00:00:00 2001 From: Mike Salvatore Date: Thu, 25 Feb 2021 20:09:12 -0500 Subject: [PATCH 09/21] ui: sort unsafe options first so they're less likely to be hidden --- .../ui/src/components/ui-components/AdvancedMultiSelect.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/monkey/monkey_island/cc/ui/src/components/ui-components/AdvancedMultiSelect.js b/monkey/monkey_island/cc/ui/src/components/ui-components/AdvancedMultiSelect.js index 670b99cd7..8503a74fc 100644 --- a/monkey/monkey_island/cc/ui/src/components/ui-components/AdvancedMultiSelect.js +++ b/monkey/monkey_island/cc/ui/src/components/ui-components/AdvancedMultiSelect.js @@ -48,13 +48,14 @@ class AdvancedMultiSelect extends React.Component { }; } - // Sort options alphabetically. "Unsafe" options float to the bottom" + // Sort options alphabetically. "Unsafe" options float to the top so that they + // do not get selected and hidden at the bottom of the list. compareOptions = (a, b) => { // Apparently, you can use additive operators with boolean types. Ultimately, // the ToNumber() abstraction operation is called to convert the booleans to // numbers: https://tc39.es/ecma262/#sec-tonumeric - if (this.isSafe(b.value) - this.isSafe(a.value) !== 0) { - return this.isSafe(b.value) - this.isSafe(a.value); + if (this.isSafe(a.value) - this.isSafe(b.value) !== 0) { + return this.isSafe(a.value) - this.isSafe(b.value); } return a.value.localeCompare(b.value); From 10a4252affb9c39649b7bc7a7720ecceccd78d92 Mon Sep 17 00:00:00 2001 From: Mike Salvatore Date: Thu, 25 Feb 2021 20:23:56 -0500 Subject: [PATCH 10/21] ui: remove unnecessary semicolons --- .../monkey_island/cc/ui/src/components/pages/ConfigurePage.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 015b3ffbb..c04fdeb93 100644 --- a/monkey/monkey_island/cc/ui/src/components/pages/ConfigurePage.js +++ b/monkey/monkey_island/cc/ui/src/components/pages/ConfigurePage.js @@ -208,7 +208,7 @@ class ConfigurePageComponent extends AuthComponent { }); this.setState({unsafeOptionsConfirmed: false}) - }; + } // Alters attack configuration when user toggles technique attackTechniqueChange = (technique, value, mapped = false) => { @@ -382,7 +382,7 @@ class ConfigurePageComponent extends AuthComponent { } this.setState({unsafeOptionsConfirmed: false}) - }; + } exportConfig = () => { this.updateConfigSection(); From f094efba8f226caa344d5a5e1859e15c66dc6fb8 Mon Sep 17 00:00:00 2001 From: Mike Salvatore Date: Fri, 26 Feb 2021 08:10:13 -0500 Subject: [PATCH 11/21] ui: minor change to unsafe modal dialog language Co-authored-by: VakarisZ <36815064+VakarisZ@users.noreply.github.com> --- .../configuration-components/UnsafeOptionsConfirmationModal.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/monkey/monkey_island/cc/ui/src/components/configuration-components/UnsafeOptionsConfirmationModal.js b/monkey/monkey_island/cc/ui/src/components/configuration-components/UnsafeOptionsConfirmationModal.js index 1fbf8b0b3..819c735b8 100644 --- a/monkey/monkey_island/cc/ui/src/components/configuration-components/UnsafeOptionsConfirmationModal.js +++ b/monkey/monkey_island/cc/ui/src/components/configuration-components/UnsafeOptionsConfirmationModal.js @@ -9,8 +9,7 @@ function UnsafeOptionsConfirmationModal(props) {
Warning

- You have selected some options which are not safe for all environments. - These options could cause some systems to become unstable or malfunction. + Some of the selected options could cause systems to become unstable or malfunction. Are you sure you want to use the selected settings?

From 7079a6fd232d8bda028a24295d1a41d787eac962 Mon Sep 17 00:00:00 2001 From: Mike Salvatore Date: Fri, 26 Feb 2021 08:39:49 -0500 Subject: [PATCH 12/21] ui: pass callback, not return value, to setState() --- .../cc/ui/src/components/pages/ConfigurePage.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) 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 c04fdeb93..b3c509bec 100644 --- a/monkey/monkey_island/cc/ui/src/components/pages/ConfigurePage.js +++ b/monkey/monkey_island/cc/ui/src/components/pages/ConfigurePage.js @@ -355,14 +355,13 @@ class ConfigurePageComponent extends AuthComponent { attemptSetConfigFromCandidateJson(newConfigCandidateJson){ this.setState({lastAction: 'import_attempt', candidateConfigJson: newConfigCandidateJson}, - this.setConfigFromCandidateJson(newConfigCandidateJson) + this.setConfigFromCandidateJson ); } - setConfigFromCandidateJson(newConfigCandidateJson){ + setConfigFromCandidateJson(){ try { - this.setState({lastAction: 'import_attempt', candidateConfigJson: newConfigCandidateJson}) - let newConfig = JSON.parse(newConfigCandidateJson); + let newConfig = JSON.parse(this.state.candidateConfigJson); if (!this.canSafelySubmitConfig(newConfig)) { this.setState({showUnsafeOptionsConfirmation: true}); From 2ef81d56889ac081bfe7fcadfb2aa2f9359505a1 Mon Sep 17 00:00:00 2001 From: Mike Salvatore Date: Fri, 26 Feb 2021 11:06:33 -0500 Subject: [PATCH 13/21] ui: change language from "use" -> submit for consistency --- .../UnsafeOptionsConfirmationModal.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/monkey/monkey_island/cc/ui/src/components/configuration-components/UnsafeOptionsConfirmationModal.js b/monkey/monkey_island/cc/ui/src/components/configuration-components/UnsafeOptionsConfirmationModal.js index 819c735b8..cb38fa823 100644 --- a/monkey/monkey_island/cc/ui/src/components/configuration-components/UnsafeOptionsConfirmationModal.js +++ b/monkey/monkey_island/cc/ui/src/components/configuration-components/UnsafeOptionsConfirmationModal.js @@ -10,7 +10,7 @@ function UnsafeOptionsConfirmationModal(props) {

Some of the selected options could cause systems to become unstable or malfunction. - Are you sure you want to use the selected settings? + Are you sure you want to submit the selected settings?

From 11c30fec1421a5174a42236633945755e8e0068a Mon Sep 17 00:00:00 2001 From: Mike Salvatore Date: Fri, 26 Feb 2021 11:08:57 -0500 Subject: [PATCH 14/21] ui: simplify `onClick()` callbacks in UnsafeOptionsConfirmationModal --- .../UnsafeOptionsConfirmationModal.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/monkey/monkey_island/cc/ui/src/components/configuration-components/UnsafeOptionsConfirmationModal.js b/monkey/monkey_island/cc/ui/src/components/configuration-components/UnsafeOptionsConfirmationModal.js index cb38fa823..8e5a3076d 100644 --- a/monkey/monkey_island/cc/ui/src/components/configuration-components/UnsafeOptionsConfirmationModal.js +++ b/monkey/monkey_island/cc/ui/src/components/configuration-components/UnsafeOptionsConfirmationModal.js @@ -17,14 +17,14 @@ function UnsafeOptionsConfirmationModal(props) { className='btn btn-success' size='lg' style={{margin: '5px'}} - onClick={() => {props.onCancelClick()}}> + onClick={props.onCancelClick}> Cancel
From 5a9cb8b4af99c6f533eade11b35316e926c957b2 Mon Sep 17 00:00:00 2001 From: Mike Salvatore Date: Fri, 26 Feb 2021 11:11:52 -0500 Subject: [PATCH 15/21] ui: switch unsafe modal cancel button to variant secondary --- .../configuration-components/UnsafeOptionsConfirmationModal.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/monkey/monkey_island/cc/ui/src/components/configuration-components/UnsafeOptionsConfirmationModal.js b/monkey/monkey_island/cc/ui/src/components/configuration-components/UnsafeOptionsConfirmationModal.js index 8e5a3076d..d21bf5601 100644 --- a/monkey/monkey_island/cc/ui/src/components/configuration-components/UnsafeOptionsConfirmationModal.js +++ b/monkey/monkey_island/cc/ui/src/components/configuration-components/UnsafeOptionsConfirmationModal.js @@ -14,7 +14,7 @@ function UnsafeOptionsConfirmationModal(props) {