From 59132e08a063a900288371cbb8999121264cd375 Mon Sep 17 00:00:00 2001 From: Itay Mizeretz Date: Sun, 24 Sep 2017 20:07:19 +0300 Subject: [PATCH] Fix warnings Semantic fix on preview panel --- .../ui/src/components/pages/ConfigurePage.js | 4 +-- .../cc/ui/src/components/pages/MapPage.js | 8 ++--- .../cc/ui/src/components/pages/ReportPage.js | 1 - .../ui/src/components/pages/RunMonkeyPage.js | 36 +++++++++---------- .../ui/src/components/pages/StartOverPage.js | 2 +- .../components/preview-pane/PreviewPane.js | 6 +++- 6 files changed, 28 insertions(+), 29 deletions(-) diff --git a/monkey_island/cc/ui/src/components/pages/ConfigurePage.js b/monkey_island/cc/ui/src/components/pages/ConfigurePage.js index 9bb4c4eeb..ff7b91c5a 100644 --- a/monkey_island/cc/ui/src/components/pages/ConfigurePage.js +++ b/monkey_island/cc/ui/src/components/pages/ConfigurePage.js @@ -98,8 +98,8 @@ class ConfigurePageComponent extends React.Component { render() { let displayedSchema = {}; if (this.state.schema.hasOwnProperty('properties')) { - displayedSchema = this.state.schema["properties"][this.state.selectedSection]; - displayedSchema["definitions"] = this.state.schema["definitions"]; + displayedSchema = this.state.schema['properties'][this.state.selectedSection]; + displayedSchema['definitions'] = this.state.schema['definitions']; } return ( diff --git a/monkey_island/cc/ui/src/components/pages/MapPage.js b/monkey_island/cc/ui/src/components/pages/MapPage.js index 2a2243389..e597ea97f 100644 --- a/monkey_island/cc/ui/src/components/pages/MapPage.js +++ b/monkey_island/cc/ui/src/components/pages/MapPage.js @@ -54,16 +54,12 @@ class MapPageComponent extends React.Component { switch (group) { case 'exploited': return '#c00'; - break; case 'tunnel': return '#aaa'; - break; case 'scan': return '#f90'; - break; case 'island': return '#aaa'; - break; } return 'black'; } @@ -113,12 +109,12 @@ class MapPageComponent extends React.Component { console.log('selection cleared.'); // eslint-disable-line no-console this.setState({selected: null, selectedType: null}); } - }; + } killAllMonkeys = () => { fetch('/api?action=killall') .then(res => res.json()) - .then(res => this.setState({killPressed: (res.status==="OK")})); + .then(res => this.setState({killPressed: (res.status === 'OK')})); }; render() { diff --git a/monkey_island/cc/ui/src/components/pages/ReportPage.js b/monkey_island/cc/ui/src/components/pages/ReportPage.js index 91f21a2bd..31fdc2965 100644 --- a/monkey_island/cc/ui/src/components/pages/ReportPage.js +++ b/monkey_island/cc/ui/src/components/pages/ReportPage.js @@ -1,6 +1,5 @@ import React from 'react'; import {Col} from 'react-bootstrap'; -import {Link} from 'react-router-dom'; class ReportPageComponent extends React.Component { constructor(props) { diff --git a/monkey_island/cc/ui/src/components/pages/RunMonkeyPage.js b/monkey_island/cc/ui/src/components/pages/RunMonkeyPage.js index c9934d619..3c20a1d77 100644 --- a/monkey_island/cc/ui/src/components/pages/RunMonkeyPage.js +++ b/monkey_island/cc/ui/src/components/pages/RunMonkeyPage.js @@ -2,7 +2,7 @@ import React from 'react'; import {Button, Col, Well, Nav, NavItem} from 'react-bootstrap'; import CopyToClipboard from 'react-copy-to-clipboard'; import {Icon} from 'react-fa'; -import {Link} from "react-router-dom"; +import {Link} from 'react-router-dom'; class RunMonkeyPageComponent extends React.Component { @@ -11,9 +11,9 @@ class RunMonkeyPageComponent extends React.Component { this.state = { ips: [], selectedIp: '0.0.0.0', - runningOnIslandState: "not_running", - runningOnClientState: "not_running", - selectedSection: "windows-32" + runningOnIslandState: 'not_running', + runningOnClientState: 'not_running', + selectedSection: 'windows-32' }; } @@ -28,9 +28,9 @@ class RunMonkeyPageComponent extends React.Component { .then(res => res.json()) .then(res =>{ if (res['is_running']) { - this.setState({runningOnIslandState: "running"}); + this.setState({runningOnIslandState: 'running'}); } else { - this.setState({runningOnIslandState: "not_running"}); + this.setState({runningOnIslandState: 'not_running'}); } }); @@ -38,9 +38,9 @@ class RunMonkeyPageComponent extends React.Component { .then(res => res.json()) .then(res => { if (res['is_running']) { - this.setState({runningOnClientState: "running"}); + this.setState({runningOnClientState: 'running'}); } else { - this.setState({runningOnClientState: "not_running"}); + this.setState({runningOnClientState: 'not_running'}); } }); @@ -68,11 +68,11 @@ class RunMonkeyPageComponent extends React.Component { .then(res => { if (res['is_running']) { this.setState({ - runningOnIslandState: "installing" + runningOnIslandState: 'installing' }); } else { this.setState({ - runningOnIslandState: "not_running" + runningOnIslandState: 'not_running' }); } @@ -81,9 +81,9 @@ class RunMonkeyPageComponent extends React.Component { }; generateCmdDiv(ip) { - let isLinux = (this.state.selectedSection.split('-')[0] === "linux"); - let is32Bit = (this.state.selectedSection.split('-')[1] === "32"); - let cmdText = ""; + let isLinux = (this.state.selectedSection.split('-')[0] === 'linux'); + let is32Bit = (this.state.selectedSection.split('-')[1] === '32'); + let cmdText = ''; if (isLinux) { cmdText = this.generateLinuxCmd(ip, is32Bit); } else { @@ -110,9 +110,9 @@ class RunMonkeyPageComponent extends React.Component { }; renderIconByState(state) { - if (state === "running") { + if (state === 'running') { return - } else if (state == "installing") { + } else if (state == 'installing') { return } else { return ''; @@ -130,13 +130,13 @@ class RunMonkeyPageComponent extends React.Component {

- Download and run locally { this.renderIconByState(this.state.runningOnClientState) } diff --git a/monkey_island/cc/ui/src/components/pages/StartOverPage.js b/monkey_island/cc/ui/src/components/pages/StartOverPage.js index 20271a6b4..26b404137 100644 --- a/monkey_island/cc/ui/src/components/pages/StartOverPage.js +++ b/monkey_island/cc/ui/src/components/pages/StartOverPage.js @@ -48,7 +48,7 @@ class StartOverPageComponent extends React.Component { fetch('/api?action=reset') .then(res => res.json()) .then(res => { - if (res["status"] == "OK") { + if (res['status'] === 'OK') { this.setState({ cleaned: true }); 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 8fe0ba8b2..d7215746d 100644 --- a/monkey_island/cc/ui/src/components/preview-pane/PreviewPane.js +++ b/monkey_island/cc/ui/src/components/preview-pane/PreviewPane.js @@ -1,5 +1,5 @@ import React from 'react'; -import {Icon} from "react-fa"; +import {Icon} from 'react-fa'; class PreviewPaneComponent extends React.Component { @@ -58,6 +58,10 @@ class PreviewPaneComponent extends React.Component { } exploitsTimeline(asset) { + if (asset.exploits.length === 0) { + return (

); + } + return (

Timeline