From a152da02d22ef2baf5a32aeec26ce1f126dc935e Mon Sep 17 00:00:00 2001 From: Mike Salvatore Date: Mon, 1 Mar 2021 12:00:05 -0500 Subject: [PATCH] ui: show warning when unsafe ATT&CK configuration is submitted --- .../UnsafeOptionsWarningModal.js | 28 +++++++++++++++++ .../ui/src/components/pages/ConfigurePage.js | 31 ++++++++++++++++--- 2 files changed, 55 insertions(+), 4 deletions(-) create mode 100644 monkey/monkey_island/cc/ui/src/components/configuration-components/UnsafeOptionsWarningModal.js diff --git a/monkey/monkey_island/cc/ui/src/components/configuration-components/UnsafeOptionsWarningModal.js b/monkey/monkey_island/cc/ui/src/components/configuration-components/UnsafeOptionsWarningModal.js new file mode 100644 index 000000000..ee25c3959 --- /dev/null +++ b/monkey/monkey_island/cc/ui/src/components/configuration-components/UnsafeOptionsWarningModal.js @@ -0,0 +1,28 @@ +import React from 'react'; +import {Modal, Button} from 'react-bootstrap'; + +function UnsafeOptionsConfirmationModal(props) { + return ( + + +

+
Warning
+

+

+ Some of the selected options could cause systems to become unstable or malfunction. +

+
+ +
+
+
+ ) +} + +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 46303198a..4cae9b2bf 100644 --- a/monkey/monkey_island/cc/ui/src/components/pages/ConfigurePage.js +++ b/monkey/monkey_island/cc/ui/src/components/pages/ConfigurePage.js @@ -12,6 +12,7 @@ import {formValidationFormats} from '../configuration-components/ValidationForma import transformErrors from '../configuration-components/ValidationErrorMessages'; import InternalConfig from '../configuration-components/InternalConfig'; import UnsafeOptionsConfirmationModal from '../configuration-components/UnsafeOptionsConfirmationModal.js'; +import UnsafeOptionsWarningModal from '../configuration-components/UnsafeOptionsWarningModal.js'; import isUnsafeOptionSelected from '../utils/SafeOptionValidator.js'; const ATTACK_URL = '/api/attack'; @@ -38,7 +39,8 @@ class ConfigurePageComponent extends AuthComponent { sections: [], selectedSection: 'attack', showAttackAlert: false, - showUnsafeOptionsConfirmation: false + showUnsafeOptionsConfirmation: false, + showUnsafeAttackOptionsWarning: false }; } @@ -92,12 +94,17 @@ class ConfigurePageComponent extends AuthComponent { } } - updateConfig = () => { + onUnsafeAttackContinueClick = () => { + this.setState({showUnsafeAttackOptionsWarning: false}); + } + + + updateConfig = (callback=null) => { this.authFetch(CONFIG_URL) .then(res => res.json()) .then(data => { this.setInitialConfig(data.configuration); - this.setState({configuration: data.configuration}); + this.setState({configuration: data.configuration}, callback); }) }; @@ -130,7 +137,7 @@ class ConfigurePageComponent extends AuthComponent { .then(() => { this.setInitialAttackConfig(this.state.attackConfig); }) - .then(() => this.updateConfig()) + .then(() => this.updateConfig(this.checkAndShowUnsafeAttackWarning)) .then(() => this.setState({lastAction: 'saved'})) .catch(error => { console.log('Bad configuration: ' + error.toString()); @@ -138,6 +145,12 @@ class ConfigurePageComponent extends AuthComponent { }); }; + checkAndShowUnsafeAttackWarning = () => { + if (isUnsafeOptionSelected(this.state.schema, this.state.configuration)) { + this.setState({showUnsafeAttackOptionsWarning: true}); + } + } + attemptConfigSubmit() { this.updateConfigSection(); this.setState({lastAction: 'submit_attempt'}, () => { @@ -243,6 +256,15 @@ class ConfigurePageComponent extends AuthComponent { ); } + renderUnsafeAttackOptionsWarningModal() { + return ( + + ); + } + userChangedConfig() { if (JSON.stringify(this.state.configuration) === JSON.stringify(this.initialConfig)) { if (Object.keys(this.currentFormData).length === 0 || @@ -468,6 +490,7 @@ class ConfigurePageComponent extends AuthComponent { className={'main'}> {this.renderAttackAlertModal()} {this.renderUnsafeOptionsConfirmationModal()} + {this.renderUnsafeAttackOptionsWarningModal()}

Monkey Configuration

{this.renderNav()} {content}