Add force-kill monkey toggle

This commit is contained in:
Itay Mizeretz 2017-09-25 11:48:16 +03:00
parent 74af4e1627
commit 4e223c5ae2
4 changed files with 29 additions and 2 deletions

View File

@ -31,7 +31,7 @@ class NodeService:
# node is infected
new_node = NodeService.monkey_to_net_node(monkey)
for key in monkey:
if key not in ["_id", "modifytime", "parent", "dead", "config"]:
if key not in ["_id", "modifytime", "parent", "dead"]:
new_node[key] = monkey[key]
else:

View File

@ -77,6 +77,7 @@
"react-jsonschema-form": "^0.49.0",
"react-redux": "^5.0.6",
"react-router-dom": "^4.2.2",
"react-toggle": "^4.0.1",
"redux": "^3.7.2"
}
}

View File

@ -13,7 +13,8 @@ import ReportPage from 'components/pages/ReportPage';
require('normalize.css/normalize.css');
require('react-data-components/css/table-twbs.css');
require('styles/App.css');
require('styles/App.css')
require('react-toggle/style.css');
let logoImage = require('../images/monkey-logo.png');
let guardicoreLogoImage = require('../images/guardicore-logo.png');

View File

@ -1,5 +1,6 @@
import React from 'react';
import {Icon} from 'react-fa';
import Toggle from 'react-toggle';
class PreviewPaneComponent extends React.Component {
@ -57,6 +58,29 @@ class PreviewPaneComponent extends React.Component {
);
}
forceKill(event, asset) {
let newConfig = asset.config;
newConfig['alive'] = !event.target.checked;
fetch('/api/monkey/' + asset.guid,
{
method: 'PATCH',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({config: newConfig})
});
}
forceKillRow(asset) {
return (
<tr>
<th>Force Kill</th>
<td>
<Toggle id={asset.id} checked={!asset.config.alive} icons={false}
onChange={(e) => this.forceKill(e, asset)} />
</td>
</tr>
);
}
exploitsTimeline(asset) {
if (asset.exploits.length === 0) {
return (<div />);
@ -106,6 +130,7 @@ class PreviewPaneComponent extends React.Component {
{this.ipsRow(asset)}
{this.servicesRow(asset)}
{this.accessibleRow(asset)}
{this.forceKillRow(asset)}
</tbody>
</table>
{this.exploitsTimeline(asset)}