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,