Merge pull request #1291 from guardicore/ransomware-reporting-tab

Add ransomware report tab
This commit is contained in:
Shreya Malviya 2021-07-06 19:59:07 +05:30 committed by GitHub
commit 999399ae2d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 67 additions and 4 deletions

View File

@ -171,6 +171,9 @@ class AppComponent extends AuthComponent {
{this.renderRoute('/report/zeroTrust',
<StandardLayoutComponent component={ReportPage}
completedSteps={this.state.completedSteps}/>)}
{this.renderRoute('/report/ransomware',
<StandardLayoutComponent component={ReportPage}
completedSteps={this.state.completedSteps}/>)}
{this.renderRoute('/license',
<StandardLayoutComponent component={LicensePage}
onStatusChange={this.updateStatus}

View File

@ -3,9 +3,10 @@ import {Route} from 'react-router-dom';
import {Col, Nav} from 'react-bootstrap';
import AuthComponent from '../AuthComponent';
import MustRunMonkeyWarning from '../report-components/common/MustRunMonkeyWarning';
import AttackReport from '../report-components/AttackReport'
import SecurityReport from '../report-components/SecurityReport'
import ZeroTrustReport from '../report-components/ZeroTrustReport'
import AttackReport from '../report-components/AttackReport';
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';
@ -14,11 +15,12 @@ class ReportPageComponent extends AuthComponent {
constructor(props) {
super(props);
this.sectionsOrder = ['security', 'zeroTrust', 'attack'];
this.sectionsOrder = ['security', 'zeroTrust', 'attack', 'ransomware'];
this.state = {
securityReport: {},
attackReport: {},
zeroTrustReport: {},
ransomwareReport: {},
allMonkeysAreDead: false,
runStarted: true,
selectedSection: ReportPageComponent.selectReport(this.sectionsOrder),
@ -56,6 +58,18 @@ class ReportPageComponent extends AuthComponent {
this.getZeroTrustReportFromServer().then((ztReport) => {
this.setState({zeroTrustReport: ztReport})
});
this.setState({
ransomwareReport: {'report': ''}})
// this.authFetch('/api/report/ransomware')
// .then(res => res.json())
// .then(res => {
// this.setState({
// ransomwareReport: res
// });
// });
if (this.shouldShowRansomwareReport(this.state.ransomwareReport)) {
this.state.sections.push({key: 'ransomware', title: 'Ransomware report'})
}
}
}
@ -84,6 +98,12 @@ class ReportPageComponent extends AuthComponent {
return ztReport
};
shouldShowRansomwareReport(report) { // TODO: Add proper check
if (report) {
return true;
}
}
componentWillUnmount() {
clearInterval(this.state.ztReportRefreshInterval);
}
@ -144,6 +164,8 @@ class ReportPageComponent extends AuthComponent {
return (<AttackReport report={this.state.attackReport}/>);
case 'zeroTrust':
return (<ZeroTrustReport report={this.state.zeroTrustReport}/>);
case 'ransomware':
return (<RansomwareReport report={this.state.ransomwareReport}/>);
}
}

View File

@ -0,0 +1,37 @@
import React from 'react';
import ReportHeader, {ReportTypes} from './common/ReportHeader';
import ReportLoader from './common/ReportLoader';
class RansomwareReport extends React.Component {
stillLoadingDataFromServer() {
return Object.keys(this.props.report).length === 0;
}
generateReportContent() {
return (
<div>
<p>
This report shows information about the ransomware simulation run by Infection Monkey.
</p>
</div>
)
}
render() {
let content = {};
if (this.stillLoadingDataFromServer()) {
content = <ReportLoader loading={true}/>;
} else {
content = <div> {this.generateReportContent()}</div>;
}
return (
<div className='report-page'>
<ReportHeader report_type={ReportTypes.ransomware}/>
<hr/>
{content}
</div>)
}
}
export default RansomwareReport;

View File

@ -8,6 +8,7 @@ export const ReportTypes = {
zeroTrust: 'Zero Trust',
security: 'Security',
attack: 'ATT&CK',
ransomware: 'Ransomware',
null: ''
};