From dd48a2e40d550a5a290095445d7764835e6b6d88 Mon Sep 17 00:00:00 2001
From: Shay Nehmad
Date: Wed, 14 Aug 2019 10:03:43 +0300
Subject: [PATCH] Extracted not all monkeys done warning and added to zero
trust report
---
.../cc/ui/src/components/pages/ReportPage.js | 14 ++-----
.../components/pages/ZeroTrustReportPage.js | 41 ++++++++++++++-----
.../common/MonkeysStillAliveWarning.js | 21 ++++++++++
3 files changed, 54 insertions(+), 22 deletions(-)
create mode 100644 monkey/monkey_island/cc/ui/src/components/report-components/common/MonkeysStillAliveWarning.js
diff --git a/monkey/monkey_island/cc/ui/src/components/pages/ReportPage.js b/monkey/monkey_island/cc/ui/src/components/pages/ReportPage.js
index d68a7b3f6..081271e12 100644
--- a/monkey/monkey_island/cc/ui/src/components/pages/ReportPage.js
+++ b/monkey/monkey_island/cc/ui/src/components/pages/ReportPage.js
@@ -12,7 +12,8 @@ import AuthComponent from '../AuthComponent';
import PassTheHashMapPageComponent from "./PassTheHashMapPage";
import StrongUsers from "components/report-components/security/StrongUsers";
import AttackReport from "components/report-components/security/AttackReport";
-import ReportHeader, { ReportTypes } from "../report-components/common/ReportHeader";
+import ReportHeader, {ReportTypes} from "../report-components/common/ReportHeader";
+import {MonkeysStillAliveWarning} from "../report-components/common/MonkeysStillAliveWarning";
let guardicoreLogoImage = require('../../images/guardicore-logo.png');
@@ -175,16 +176,7 @@ class ReportPageComponent extends AuthComponent {
No critical security issues were detected.
)
}
- {
- this.state.allMonkeysAreDead ?
- ''
- :
- (
-
- Some monkeys are still running. To get the best report it's best to wait for all of them to finish
- running.
-
)
- }
+
{
this.state.report.glance.exploited.length > 0 ?
''
diff --git a/monkey/monkey_island/cc/ui/src/components/pages/ZeroTrustReportPage.js b/monkey/monkey_island/cc/ui/src/components/pages/ZeroTrustReportPage.js
index 1dfe0c40b..665bf4b02 100644
--- a/monkey/monkey_island/cc/ui/src/components/pages/ZeroTrustReportPage.js
+++ b/monkey/monkey_island/cc/ui/src/components/pages/ZeroTrustReportPage.js
@@ -5,6 +5,7 @@ import ReportHeader, {ReportTypes} from "../report-components/common/ReportHeade
import PillarGrades from "../report-components/zerotrust/PillarGrades";
import FindingsTable from "../report-components/zerotrust/FindingsTable";
import {SinglePillarDirectivesStatus} from "../report-components/zerotrust/SinglePillarDirectivesStatus";
+import {MonkeysStillAliveWarning} from "../report-components/common/MonkeysStillAliveWarning";
class ZeroTrustReportPageComponent extends AuthComponent {
@@ -13,16 +14,30 @@ class ZeroTrustReportPageComponent extends AuthComponent {
this.state = {
allMonkeysAreDead: false,
- runStarted: false
+ runStarted: true
};
}
- render() {
- let res;
- // Todo move to componentDidMount
- this.getZeroTrustReportFromServer(res);
+ componentDidMount() {
+ this.updateMonkeysRunning().then(res => this.getZeroTrustReportFromServer(res));
+ }
- const content = this.generateReportContent();
+ updateMonkeysRunning = () => {
+ return this.authFetch('/api')
+ .then(res => res.json())
+ .then(res => {
+ this.setState({
+ allMonkeysAreDead: (!res['completed_steps']['run_monkey']) || (res['completed_steps']['infection_done']),
+ runStarted: res['completed_steps']['run_monkey']
+ });
+ return res;
+ });
+ };
+
+ render() {
+ let content;
+
+ content = this.generateReportContent();
return (
@@ -40,12 +55,13 @@ class ZeroTrustReportPageComponent extends AuthComponent {
if (this.stillLoadingDataFromServer()) {
content = "Still empty";
} else {
- const pillarsSection =
+ const pillarsSection =
;
- const directivesSection =
Directives status
+ const directivesSection =
+
Directives status
{
Object.keys(this.state.directives).map((pillar) =>
;
- const findingSection = Findings
- ;
+ const findingSection =
+
Findings
+
+ ;
- content =
+ content =
+
{pillarsSection}
{directivesSection}
{findingSection}
diff --git a/monkey/monkey_island/cc/ui/src/components/report-components/common/MonkeysStillAliveWarning.js b/monkey/monkey_island/cc/ui/src/components/report-components/common/MonkeysStillAliveWarning.js
new file mode 100644
index 000000000..67fd9388a
--- /dev/null
+++ b/monkey/monkey_island/cc/ui/src/components/report-components/common/MonkeysStillAliveWarning.js
@@ -0,0 +1,21 @@
+import React, {Component} from "react";
+import * as PropTypes from "prop-types";
+
+export class MonkeysStillAliveWarning extends Component {
+ render() {
+ return
+ {
+ this.props.allMonkeysAreDead ?
+ ''
+ :
+ (
+
+ Some monkeys are still running. To get the best report it's best to wait for all of them to finish
+ running.
+
)
+ }
+
+ }
+}
+
+MonkeysStillAliveWarning.propTypes = {allMonkeysAreDead: PropTypes.bool};