From 64a8d714395cd93ebc2bd7e04678df96d1d4a15e Mon Sep 17 00:00:00 2001 From: VakarisZ Date: Mon, 27 Jul 2020 16:48:33 +0300 Subject: [PATCH] Added the the ability to assing info/warnings to configuration fields/sections. Moved network warning under "Scope" --- .../services/config_schema/basic_network.py | 4 +++- .../configuration-components/FieldWithInfo.js | 20 +++++++++++++++++++ .../configuration-components/UiSchema.js | 6 +++++- .../ui/src/components/pages/ConfigurePage.js | 14 ------------- 4 files changed, 28 insertions(+), 16 deletions(-) create mode 100644 monkey/monkey_island/cc/ui/src/components/configuration-components/FieldWithInfo.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 0fd3344e8..33467690a 100644 --- a/monkey/monkey_island/cc/services/config_schema/basic_network.py +++ b/monkey/monkey_island/cc/services/config_schema/basic_network.py @@ -19,7 +19,9 @@ BASIC_NETWORK = { }, "default": [ ], - "description": "List of IPs that the Monkey will not scan." + "description": "List of IPs that the Monkey will not scan.", + "info": "The Monkey scans its subnet if \"Local network scan\" is ticked. " + "Additionally the monkey scans machines according to \"Scan target list\"." }, "local_network_scan": { "title": "Local network scan", diff --git a/monkey/monkey_island/cc/ui/src/components/configuration-components/FieldWithInfo.js b/monkey/monkey_island/cc/ui/src/components/configuration-components/FieldWithInfo.js new file mode 100644 index 000000000..8a0bc0c04 --- /dev/null +++ b/monkey/monkey_island/cc/ui/src/components/configuration-components/FieldWithInfo.js @@ -0,0 +1,20 @@ +import ObjectField from 'react-jsonschema-form-bs4/lib/components/fields/ArrayField'; +import * as React from 'react'; +import {FontAwesomeIcon} from '@fortawesome/react-fontawesome'; +import {faInfoCircle} from '@fortawesome/free-solid-svg-icons/faInfoCircle'; + +class FieldWithInfo extends React.Component { + + render() { + return ( + <> +
+ + {this.props.schema.info} +
+ + ); + } +} + +export default FieldWithInfo; 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 914d23ed3..aab3f1899 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 @@ -1,6 +1,7 @@ import AdvancedMultiSelect from '../ui-components/AdvancedMultiSelect'; import PbaInput from './PbaInput'; import {API_PBA_LINUX, API_PBA_WINDOWS} from '../pages/ConfigurePage'; +import FieldWithInfo from './FieldWithInfo'; export default function UiSchema(props) { const UiSchema = { @@ -16,7 +17,10 @@ export default function UiSchema(props) { basic_network: { 'ui:order': ['scope', 'network_analysis'], scope: { - subnet_scan_list:{ + blocked_ips: { + 'ui:field': FieldWithInfo + }, + subnet_scan_list: { format: 'ip-list' } } 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 dd38a3cf0..7da7ca14c 100644 --- a/monkey/monkey_island/cc/ui/src/components/pages/ConfigurePage.js +++ b/monkey/monkey_island/cc/ui/src/components/pages/ConfigurePage.js @@ -6,7 +6,6 @@ import AuthComponent from '../AuthComponent'; import ConfigMatrixComponent from '../attack/ConfigMatrixComponent'; import UiSchema from '../configuration-components/UiSchema'; import {FontAwesomeIcon} from '@fortawesome/react-fontawesome'; -import {faInfoCircle} from '@fortawesome/free-solid-svg-icons/faInfoCircle'; import {faCheck} from '@fortawesome/free-solid-svg-icons/faCheck'; import {faExclamationCircle} from '@fortawesome/free-solid-svg-icons/faExclamationCircle'; import {formValidationFormats} from '../configuration-components/ValidationFormats'; @@ -352,7 +351,6 @@ class ConfigurePageComponent extends AuthComponent { } else { return (
- {this.renderBasicNetworkWarning()}
@@ -377,18 +375,6 @@ class ConfigurePageComponent extends AuthComponent { }) } - renderBasicNetworkWarning = () => { - if (this.state.selectedSection === 'basic_network') { - return (
- - The Monkey scans its subnet if "Local network scan" is ticked. Additionally the monkey scans machines - according to "Scan target list". -
) - } else { - return (
) - } - }; - renderNav = () => { return (