From 8ee3ab4317ede019b6b3d5880e1899c5f42b70cd Mon Sep 17 00:00:00 2001 From: Ilija Lazoroski Date: Thu, 15 Jul 2021 18:15:15 +0200 Subject: [PATCH 1/2] UI: Fix submit config when nothing is changed on Ransomware and Network Tabs --- .../cc/services/config_schema/basic_network.py | 2 +- .../cc/services/config_schema/ransomware.py | 9 ++++----- .../components/configuration-components/TextBox.js | 14 ++++++++++++++ .../configuration-components/UiSchema.js | 4 ++++ .../cc/ui/src/components/pages/ConfigurePage.js | 2 +- 5 files changed, 24 insertions(+), 7 deletions(-) create mode 100644 monkey/monkey_island/cc/ui/src/components/configuration-components/TextBox.js diff --git a/monkey/monkey_island/cc/services/config_schema/basic_network.py b/monkey/monkey_island/cc/services/config_schema/basic_network.py index e1dd95c17..02f87c7cf 100644 --- a/monkey/monkey_island/cc/services/config_schema/basic_network.py +++ b/monkey/monkey_island/cc/services/config_schema/basic_network.py @@ -11,7 +11,7 @@ BASIC_NETWORK = { "properties": { "info_box": { "title": "", - "type": "object", + "type": "text", "info": 'The Monkey scans its subnet if "Local network scan" is checked. ' 'Additionally, the Monkey scans machines according to "Scan ' 'target list".', diff --git a/monkey/monkey_island/cc/services/config_schema/ransomware.py b/monkey/monkey_island/cc/services/config_schema/ransomware.py index 03c5e8438..7ec3d793f 100644 --- a/monkey/monkey_island/cc/services/config_schema/ransomware.py +++ b/monkey/monkey_island/cc/services/config_schema/ransomware.py @@ -24,7 +24,7 @@ RANSOMWARE = { }, "info_box": { "title": "", - "type": "object", + "type": "text", "info": "No files will be encrypted if a directory is not specified or doesn't " "exist on a victim machine.", }, @@ -52,11 +52,10 @@ RANSOMWARE = { }, }, }, - "readme_note": { + "text_box": { "title": "", - "type": "object", - "description": "Note: A README.txt will be left in the specified target " - "directory.", + "type": "text", + "text": "Note: A README.txt will be left in the specified target " "directory.", }, }, }, diff --git a/monkey/monkey_island/cc/ui/src/components/configuration-components/TextBox.js b/monkey/monkey_island/cc/ui/src/components/configuration-components/TextBox.js new file mode 100644 index 000000000..f32803195 --- /dev/null +++ b/monkey/monkey_island/cc/ui/src/components/configuration-components/TextBox.js @@ -0,0 +1,14 @@ +import * as React from 'react'; + +class TextBox extends React.Component { + + render() { + return ( + <> +

{this.props.schema.text}

+ + ); + } +} + +export default TextBox; diff --git a/monkey/monkey_island/cc/ui/src/components/configuration-components/UiSchema.js b/monkey/monkey_island/cc/ui/src/components/configuration-components/UiSchema.js index 5d1211407..38e7ad244 100644 --- a/monkey/monkey_island/cc/ui/src/components/configuration-components/UiSchema.js +++ b/monkey/monkey_island/cc/ui/src/components/configuration-components/UiSchema.js @@ -2,6 +2,7 @@ import AdvancedMultiSelect from '../ui-components/AdvancedMultiSelect'; import PbaInput from './PbaInput'; import {API_PBA_LINUX, API_PBA_WINDOWS} from '../pages/ConfigurePage'; import InfoBox from './InfoBox'; +import TextBox from './TextBox'; export default function UiSchema(props) { const UiSchema = { @@ -79,6 +80,9 @@ export default function UiSchema(props) { directories: { // Directory inputs are dynamically hidden }, + text_box: { + 'ui:field': TextBox + }, enabled: {'ui:widget': 'hidden'} }, other_behaviors : {'ui:widget': 'hidden'} 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 c7c84e327..321974b0c 100644 --- a/monkey/monkey_island/cc/ui/src/components/pages/ConfigurePage.js +++ b/monkey/monkey_island/cc/ui/src/components/pages/ConfigurePage.js @@ -58,7 +58,7 @@ class ConfigurePageComponent extends AuthComponent { } getSectionsOrder() { - let islandMode = this.props.islandMode ? this.props.islandMode : 'advanced' + let islandMode = 'advanced' return CONFIGURATION_TABS_PER_MODE[islandMode]; } From 752ea6af105cbc553178797c82086f2dcdf2be01 Mon Sep 17 00:00:00 2001 From: Ilija Lazoroski Date: Fri, 16 Jul 2021 09:31:14 +0200 Subject: [PATCH 2/2] ui: Remove title and type from config schema --- .../monkey_island/cc/services/config_schema/basic_network.py | 2 -- monkey/monkey_island/cc/services/config_schema/ransomware.py | 4 ---- .../cc/ui/src/components/configuration-components/TextBox.js | 4 +--- .../monkey_island/cc/ui/src/components/pages/ConfigurePage.js | 2 +- 4 files changed, 2 insertions(+), 10 deletions(-) diff --git a/monkey/monkey_island/cc/services/config_schema/basic_network.py b/monkey/monkey_island/cc/services/config_schema/basic_network.py index 02f87c7cf..eceda4828 100644 --- a/monkey/monkey_island/cc/services/config_schema/basic_network.py +++ b/monkey/monkey_island/cc/services/config_schema/basic_network.py @@ -10,8 +10,6 @@ BASIC_NETWORK = { "type": "object", "properties": { "info_box": { - "title": "", - "type": "text", "info": 'The Monkey scans its subnet if "Local network scan" is checked. ' 'Additionally, the Monkey scans machines according to "Scan ' 'target list".', diff --git a/monkey/monkey_island/cc/services/config_schema/ransomware.py b/monkey/monkey_island/cc/services/config_schema/ransomware.py index 7ec3d793f..dd77a175d 100644 --- a/monkey/monkey_island/cc/services/config_schema/ransomware.py +++ b/monkey/monkey_island/cc/services/config_schema/ransomware.py @@ -23,8 +23,6 @@ RANSOMWARE = { "in the files contained within the target directories.", }, "info_box": { - "title": "", - "type": "text", "info": "No files will be encrypted if a directory is not specified or doesn't " "exist on a victim machine.", }, @@ -53,8 +51,6 @@ RANSOMWARE = { }, }, "text_box": { - "title": "", - "type": "text", "text": "Note: A README.txt will be left in the specified target " "directory.", }, }, diff --git a/monkey/monkey_island/cc/ui/src/components/configuration-components/TextBox.js b/monkey/monkey_island/cc/ui/src/components/configuration-components/TextBox.js index f32803195..4d24ddb0a 100644 --- a/monkey/monkey_island/cc/ui/src/components/configuration-components/TextBox.js +++ b/monkey/monkey_island/cc/ui/src/components/configuration-components/TextBox.js @@ -4,9 +4,7 @@ class TextBox extends React.Component { render() { return ( - <> -

{this.props.schema.text}

- +

{this.props.schema.text}

); } } 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 321974b0c..c7c84e327 100644 --- a/monkey/monkey_island/cc/ui/src/components/pages/ConfigurePage.js +++ b/monkey/monkey_island/cc/ui/src/components/pages/ConfigurePage.js @@ -58,7 +58,7 @@ class ConfigurePageComponent extends AuthComponent { } getSectionsOrder() { - let islandMode = 'advanced' + let islandMode = this.props.islandMode ? this.props.islandMode : 'advanced' return CONFIGURATION_TABS_PER_MODE[islandMode]; }