From 46ac53c5d1d931f6ea883e4677edf52a45a6ae9e Mon Sep 17 00:00:00 2001 From: Shreya Date: Fri, 2 Jul 2021 13:53:45 +0530 Subject: [PATCH 1/5] cc: Add ransomware report tab --- .../cc/ui/src/components/Main.js | 3 ++ .../cc/ui/src/components/pages/ReportPage.js | 25 ++++++++--- .../report-components/RansomwareReport.js | 45 +++++++++++++++++++ .../report-components/common/ReportHeader.js | 1 + 4 files changed, 69 insertions(+), 5 deletions(-) create mode 100644 monkey/monkey_island/cc/ui/src/components/report-components/RansomwareReport.js diff --git a/monkey/monkey_island/cc/ui/src/components/Main.js b/monkey/monkey_island/cc/ui/src/components/Main.js index 32480db8e..b5fc5f606 100644 --- a/monkey/monkey_island/cc/ui/src/components/Main.js +++ b/monkey/monkey_island/cc/ui/src/components/Main.js @@ -171,6 +171,9 @@ class AppComponent extends AuthComponent { {this.renderRoute('/report/zeroTrust', )} + {this.renderRoute('/report/ransomware', + )} {this.renderRoute('/license', { this.setState({zeroTrustReport: ztReport}) }); + this.setState({ + ransomwareReport: {'report': ''} + }); + // this.authFetch('/api/report/ransomware') + // .then(res => res.json()) + // .then(res => { + // this.setState({ + // ransomwareReport: res + // }); + // }); } } @@ -144,6 +157,8 @@ class ReportPageComponent extends AuthComponent { return (); case 'zeroTrust': return (); + case 'ransomware': + return (); } } diff --git a/monkey/monkey_island/cc/ui/src/components/report-components/RansomwareReport.js b/monkey/monkey_island/cc/ui/src/components/report-components/RansomwareReport.js new file mode 100644 index 000000000..31629fbf0 --- /dev/null +++ b/monkey/monkey_island/cc/ui/src/components/report-components/RansomwareReport.js @@ -0,0 +1,45 @@ +import React from 'react'; + +import ReportHeader, {ReportTypes} from './common/ReportHeader'; +import ReportLoader from './common/ReportLoader'; + +class RansomwareReport extends React.Component { + + constructor(props) { + super(props); + this.state = { + report: props.report + }; + } + + stillLoadingDataFromServer() { + return Object.keys(this.state.report).length === 0; + } + + generateReportContent() { + return ( +
+

+ This report shows information about the ransomware simulation run by Infection Monkey. +

+
+ ) + } + + render() { + let content = {}; + if (this.stillLoadingDataFromServer()) { + content = ; + } else { + content =
{this.generateReportContent()}
; + } + return ( +
+ +
+ {content} +
) + } +} + +export default RansomwareReport; diff --git a/monkey/monkey_island/cc/ui/src/components/report-components/common/ReportHeader.js b/monkey/monkey_island/cc/ui/src/components/report-components/common/ReportHeader.js index d942a53e2..6e7c25d2e 100644 --- a/monkey/monkey_island/cc/ui/src/components/report-components/common/ReportHeader.js +++ b/monkey/monkey_island/cc/ui/src/components/report-components/common/ReportHeader.js @@ -8,6 +8,7 @@ export const ReportTypes = { zeroTrust: 'Zero Trust', security: 'Security', attack: 'ATT&CK', + ransomware: 'Ransomware', null: '' }; From 2f090f006094300d292f1c369722afd5d8e8dcbf Mon Sep 17 00:00:00 2001 From: Shreya Date: Mon, 5 Jul 2021 15:04:10 +0530 Subject: [PATCH 2/5] cc: Only show ransomware report tab if `show` in ransomware report telemetry is `true` --- .../cc/ui/src/components/pages/ReportPage.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) 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 dae6e676e..9138764fd 100644 --- a/monkey/monkey_island/cc/ui/src/components/pages/ReportPage.js +++ b/monkey/monkey_island/cc/ui/src/components/pages/ReportPage.js @@ -26,8 +26,7 @@ class ReportPageComponent extends AuthComponent { selectedSection: ReportPageComponent.selectReport(this.sectionsOrder), sections: [{key: 'security', title: 'Security report'}, {key: 'zeroTrust', title: 'Zero trust report'}, - {key: 'attack', title: 'ATT&CK report'}, - {key: 'ransomware', title: 'Ransomware report'}] + {key: 'attack', title: 'ATT&CK report'}] }; } @@ -60,8 +59,8 @@ class ReportPageComponent extends AuthComponent { this.setState({zeroTrustReport: ztReport}) }); this.setState({ - ransomwareReport: {'report': ''} - }); + ransomwareReport: {'report': '', + 'show': true}}) // this.authFetch('/api/report/ransomware') // .then(res => res.json()) // .then(res => { @@ -69,6 +68,9 @@ class ReportPageComponent extends AuthComponent { // ransomwareReport: res // }); // }); + if (this.state.ransomwareReport['show'] === true) { + this.state.sections.push({key: 'ransomware', title: 'Ransomware report'}) + } } } From 231fa6f99f485d9560de2bb5370dfa8f0240bc12 Mon Sep 17 00:00:00 2001 From: Shreya Date: Tue, 6 Jul 2021 15:44:40 +0530 Subject: [PATCH 3/5] cc: Add dummy code to frontend to check if ransomware report tab should be showed --- .../cc/ui/src/components/pages/ReportPage.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) 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 9138764fd..6548f5de1 100644 --- a/monkey/monkey_island/cc/ui/src/components/pages/ReportPage.js +++ b/monkey/monkey_island/cc/ui/src/components/pages/ReportPage.js @@ -59,8 +59,7 @@ class ReportPageComponent extends AuthComponent { this.setState({zeroTrustReport: ztReport}) }); this.setState({ - ransomwareReport: {'report': '', - 'show': true}}) + ransomwareReport: {'report': ''}}) // this.authFetch('/api/report/ransomware') // .then(res => res.json()) // .then(res => { @@ -68,7 +67,7 @@ class ReportPageComponent extends AuthComponent { // ransomwareReport: res // }); // }); - if (this.state.ransomwareReport['show'] === true) { + if (this.shouldShowRansomwareReport(this.state.ransomwareReport)) { this.state.sections.push({key: 'ransomware', title: 'Ransomware report'}) } } @@ -99,6 +98,12 @@ class ReportPageComponent extends AuthComponent { return ztReport }; + shouldShowRansomwareReport(report) { // TODO: Add proper check + if (report) { + return true; + } + } + componentWillUnmount() { clearInterval(this.state.ztReportRefreshInterval); } From 4d8258ddbdaad8b757a535807f05941c6197d799 Mon Sep 17 00:00:00 2001 From: Shreya Date: Tue, 6 Jul 2021 16:23:27 +0530 Subject: [PATCH 4/5] cc: Change order of report tab imports to match the order in which they're shown --- monkey/monkey_island/cc/ui/src/components/pages/ReportPage.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 6548f5de1..86b73dbb4 100644 --- a/monkey/monkey_island/cc/ui/src/components/pages/ReportPage.js +++ b/monkey/monkey_island/cc/ui/src/components/pages/ReportPage.js @@ -4,9 +4,9 @@ import {Col, Nav} from 'react-bootstrap'; import AuthComponent from '../AuthComponent'; import MustRunMonkeyWarning from '../report-components/common/MustRunMonkeyWarning'; import AttackReport from '../report-components/AttackReport'; -import RansomwareReport from '../report-components/RansomwareReport'; import SecurityReport from '../report-components/SecurityReport'; import ZeroTrustReport from '../report-components/ZeroTrustReport'; +import RansomwareReport from '../report-components/RansomwareReport'; import {extractExecutionStatusFromServerResponse} from '../report-components/common/ExecutionStatus'; import MonkeysStillAliveWarning from '../report-components/common/MonkeysStillAliveWarning'; From 6622fc0ff5bc81949a55b04988fdba38bfb2191c Mon Sep 17 00:00:00 2001 From: Mike Salvatore Date: Tue, 6 Jul 2021 10:10:33 -0400 Subject: [PATCH 5/5] Island: Do not set state from props in RansomwareReport --- .../components/report-components/RansomwareReport.js | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/monkey/monkey_island/cc/ui/src/components/report-components/RansomwareReport.js b/monkey/monkey_island/cc/ui/src/components/report-components/RansomwareReport.js index 31629fbf0..86ba1ebf4 100644 --- a/monkey/monkey_island/cc/ui/src/components/report-components/RansomwareReport.js +++ b/monkey/monkey_island/cc/ui/src/components/report-components/RansomwareReport.js @@ -4,16 +4,8 @@ import ReportHeader, {ReportTypes} from './common/ReportHeader'; import ReportLoader from './common/ReportLoader'; class RansomwareReport extends React.Component { - - constructor(props) { - super(props); - this.state = { - report: props.report - }; - } - stillLoadingDataFromServer() { - return Object.keys(this.state.report).length === 0; + return Object.keys(this.props.report).length === 0; } generateReportContent() {