diff --git a/monkey/monkey_island/cc/app.py b/monkey/monkey_island/cc/app.py index 243f1f71a..d0eff1da8 100644 --- a/monkey/monkey_island/cc/app.py +++ b/monkey/monkey_island/cc/app.py @@ -100,7 +100,7 @@ def init_app(mongo_url): with app.app_context(): database.init() - Database.reset_db() + Database.init_db() app.add_url_rule('/', 'serve_home', serve_home) app.add_url_rule('/', 'serve_static_file', serve_static_file) diff --git a/monkey/monkey_island/cc/services/database.py b/monkey/monkey_island/cc/services/database.py index ead2b2058..62e370e44 100644 --- a/monkey/monkey_island/cc/services/database.py +++ b/monkey/monkey_island/cc/services/database.py @@ -23,3 +23,9 @@ class Database(object): AttackConfig.reset_config() logger.info('DB was reset') return jsonify(status='OK') + + @staticmethod + def init_db(): + if not mongo.db.collection_names(): + Database.reset_db() + diff --git a/monkey/monkey_island/cc/ui/src/components/attack/MatrixComponent.js b/monkey/monkey_island/cc/ui/src/components/attack/MatrixComponent.js index 1df65a50e..aae3dc4e8 100644 --- a/monkey/monkey_island/cc/ui/src/components/attack/MatrixComponent.js +++ b/monkey/monkey_island/cc/ui/src/components/attack/MatrixComponent.js @@ -96,24 +96,29 @@ class MatrixComponent extends AuthComponent { return {'columns': columns, 'matrixTableData': matrixTableData, 'maxTechniques': maxTechniques} }; + renderLegend = () => { + return ( + ) + }; + render() { let tableData = this.getTableData(this.props.configuration); return (
- + {this.renderLegend()}
{ - console.log('bad attack configuration'); this.setState({lastAction: 'invalid_configuration'}); }); }; @@ -410,58 +413,79 @@ class ConfigurePageComponent extends AuthComponent { return pbaFile } + renderMatrix = () => { + return () + }; + + + renderConfigContent = (displayedSchema) => { + return (
+ {this.renderBasicNetworkWarning()} +
+ +
+
) + }; + + renderRunningMonkeysWarning = () => { + return (
+ { this.state.allMonkeysAreDead ? + '' : +
+ + Some monkeys are currently running. Note that changing the configuration will only apply to new + infections. +
+ } +
) + }; + + 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 its range class. +
) + } else { + return (
) + } + }; + + renderNav = () => { + return () + }; + render() { let displayedSchema = {}; if (this.state.schema.hasOwnProperty('properties') && this.state.selectedSection !== 'attack') { displayedSchema = this.state.schema['properties'][this.state.selectedSection]; displayedSchema['definitions'] = this.state.schema['definitions']; } - let config_content = (
-
- { this.state.allMonkeysAreDead ? - '' : -
- - Some monkeys are currently running. Note that changing the configuration will only apply to new - infections. -
- } -
- ); - let attack_content = (); let content = ''; if (this.state.selectedSection === 'attack' && Object.entries(this.state.attackConfig).length !== 0 ) { - content = attack_content + content = this.renderMatrix() } else if(this.state.selectedSection !== 'attack') { - content = config_content + content = this.renderConfigContent(displayedSchema) } - return ( {this.renderAttackAlertModal()}

Monkey Configuration

- - { - this.state.selectedSection === 'basic_network' ? -
- - The Monkey scans its subnet if "Local network scan" is ticked. Additionally the monkey scans machines - according to its range class. -
- :
- } + {this.renderNav()} + { this.renderRunningMonkeysWarning()} { content }