diff --git a/monkey_island/cc/app.py b/monkey_island/cc/app.py index 1a2bf36ac..c62c2a6c3 100644 --- a/monkey_island/cc/app.py +++ b/monkey_island/cc/app.py @@ -3,6 +3,7 @@ import bson from bson.json_util import dumps from flask import Flask, send_from_directory, redirect, make_response import flask_restful +from werkzeug.exceptions import NotFound from cc.database import mongo from cc.resources.client_run import ClientRun @@ -20,15 +21,14 @@ from cc.services.config import ConfigService __author__ = 'Barak' -def serve_static_file(path): - print 'requested', path - if path.startswith('api/'): - return make_response(404) - return send_from_directory('ui/dist', path) + +def serve_static_file(static_path): + if static_path.startswith('api/'): + raise NotFound() + return send_from_directory('ui/dist', static_path) def serve_home(): - # TODO: remove this or merge with frontend. return serve_static_file('index.html') @@ -71,7 +71,7 @@ def init_app(mongo_url): ConfigService.init_config() app.add_url_rule('/', 'serve_home', serve_home) - app.add_url_rule('/', 'serve_static_file', serve_static_file) + app.add_url_rule('/', 'serve_static_file', serve_static_file) api.add_resource(Root, '/api') api.add_resource(Monkey, '/api/monkey', '/api/monkey/', '/api/monkey/') diff --git a/monkey_island/cc/services/edge.py b/monkey_island/cc/services/edge.py index 446f359e1..a412b8103 100644 --- a/monkey_island/cc/services/edge.py +++ b/monkey_island/cc/services/edge.py @@ -18,11 +18,7 @@ class EdgeService: @staticmethod def get_displayed_edges_by_to(to): edges = mongo.db.edge.find({"to": ObjectId(to)}) - new_edges = [] - # TODO: find better solution for this - for i in range(edges.count()): - new_edges.append(EdgeService.edge_to_displayed_edge(edges[i])) - return new_edges + return [EdgeService.edge_to_displayed_edge(edge) for edge in edges] @staticmethod def edge_to_displayed_edge(edge): @@ -154,7 +150,6 @@ class EdgeService: @staticmethod def services_to_displayed_services(services): - # TODO: Consider returning extended information on services. return [x + ": " + services[x]["name"] for x in services] @staticmethod diff --git a/monkey_island/cc/ui/src/components/pages/ConfigurePage.js b/monkey_island/cc/ui/src/components/pages/ConfigurePage.js index dbd8f3991..adfbfbcac 100644 --- a/monkey_island/cc/ui/src/components/pages/ConfigurePage.js +++ b/monkey_island/cc/ui/src/components/pages/ConfigurePage.js @@ -35,12 +35,7 @@ class ConfigurePageComponent extends React.Component { onSubmit = ({formData}) => { this.currentFormData = formData; - let newConfig = this.state.configuration; - if (this.currentFormData != {}) { - newConfig[this.currentSection] = this.currentFormData; - this.currentFormData = {}; - } - this.setState({configuration: newConfig}); + this.updateConfigSection(); fetch('/api/configuration', { method: 'POST', @@ -62,17 +57,20 @@ class ConfigurePageComponent extends React.Component { this.currentFormData = formData; }; - // TODO: remove code duplication - setSelectedSection = (key) => { + updateConfigSection = () => { let newConfig = this.state.configuration; if (Object.keys(this.currentFormData).length > 0) { newConfig[this.currentSection] = this.currentFormData; this.currentFormData = {}; } + this.setState({configuration: newConfig}); + }; + + setSelectedSection = (key) => { + this.updateConfigSection(); this.currentSection = key; this.setState({ - selectedSection: key, - configuration: newConfig + selectedSection: key }); }; diff --git a/monkey_island/cc/ui/src/components/preview-pane/PreviewPane.js b/monkey_island/cc/ui/src/components/preview-pane/PreviewPane.js index a353714f2..03d7e4030 100644 --- a/monkey_island/cc/ui/src/components/preview-pane/PreviewPane.js +++ b/monkey_island/cc/ui/src/components/preview-pane/PreviewPane.js @@ -30,8 +30,6 @@ class PreviewPaneComponent extends React.Component { } infectedAssetInfo(asset) { - // TODO: Have exploit info expandable (show detailed attempts) - // TODO: consider showing scans with exploits on same timeline return (
{this.assetInfo(asset)} diff --git a/monkey_island/cc/utils.py b/monkey_island/cc/utils.py index 69b12612b..34026b157 100644 --- a/monkey_island/cc/utils.py +++ b/monkey_island/cc/utils.py @@ -18,6 +18,7 @@ if sys.platform == "win32": return socket.gethostbyname_ex(local_hostname)[2] else: import fcntl + def local_ips(): result = [] try: