forked from p15670423/monkey
Minor bugfix, changes that allow page refresh to lead to the same report
This commit is contained in:
parent
f5f0a60cb4
commit
c6d941637b
|
@ -1,5 +1,5 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import {BrowserRouter as Router, NavLink, Redirect, Route} from 'react-router-dom';
|
import {BrowserRouter as Router, NavLink, Redirect, Route, Switch} from 'react-router-dom';
|
||||||
import {Col, Grid, Row} from 'react-bootstrap';
|
import {Col, Grid, Row} from 'react-bootstrap';
|
||||||
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
|
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
|
||||||
import { faCheck, faUndo } from '@fortawesome/free-solid-svg-icons'
|
import { faCheck, faUndo } from '@fortawesome/free-solid-svg-icons'
|
||||||
|
@ -97,6 +97,11 @@ class AppComponent extends AuthComponent {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static isReportUrl(){
|
||||||
|
let url = window.location.href;
|
||||||
|
return ( url.endsWith('/report/security') || url.endsWith('/report/attack') || url.endsWith('/report/zeroTrust'))
|
||||||
|
}
|
||||||
|
|
||||||
// Sets the property that indicates if we need to remove PBA files from state or not
|
// Sets the property that indicates if we need to remove PBA files from state or not
|
||||||
setRemovePBAfiles = (rmFiles) => {
|
setRemovePBAfiles = (rmFiles) => {
|
||||||
this.setState({removePBAfiles: rmFiles});
|
this.setState({removePBAfiles: rmFiles});
|
||||||
|
@ -151,7 +156,7 @@ class AppComponent extends AuthComponent {
|
||||||
</NavLink>
|
</NavLink>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<NavLink to="/report/security">
|
<NavLink to="/report/security" className={AppComponent.isReportUrl() ? "active" : ""}>
|
||||||
<span className="number">4.</span>
|
<span className="number">4.</span>
|
||||||
Security Reports
|
Security Reports
|
||||||
{this.state.completedSteps.report_done ?
|
{this.state.completedSteps.report_done ?
|
||||||
|
@ -193,7 +198,11 @@ class AppComponent extends AuthComponent {
|
||||||
{this.renderRoute('/infection/map', <MapPage onStatusChange={this.updateStatus}/>)}
|
{this.renderRoute('/infection/map', <MapPage onStatusChange={this.updateStatus}/>)}
|
||||||
{this.renderRoute('/infection/telemetry', <TelemetryPage onStatusChange={this.updateStatus}/>)}
|
{this.renderRoute('/infection/telemetry', <TelemetryPage onStatusChange={this.updateStatus}/>)}
|
||||||
{this.renderRoute('/start-over', <StartOverPage onStatusChange={this.updateStatus}/>)}
|
{this.renderRoute('/start-over', <StartOverPage onStatusChange={this.updateStatus}/>)}
|
||||||
|
<Switch>
|
||||||
{this.renderRoute('/report/security', <ReportPage/>)}
|
{this.renderRoute('/report/security', <ReportPage/>)}
|
||||||
|
{this.renderRoute('/report/attack', <ReportPage/>)}
|
||||||
|
{this.renderRoute('/report/zeroTrust', <ReportPage/>)}
|
||||||
|
</Switch>
|
||||||
{this.renderRoute(reportZeroTrustRoute, <ZeroTrustReportPage onStatusChange={this.updateStatus}/>)}
|
{this.renderRoute(reportZeroTrustRoute, <ZeroTrustReportPage onStatusChange={this.updateStatus}/>)}
|
||||||
{this.renderRoute('/license', <LicensePage onStatusChange={this.updateStatus}/>)}
|
{this.renderRoute('/license', <LicensePage onStatusChange={this.updateStatus}/>)}
|
||||||
</Col>
|
</Col>
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import '../../styles/report/ReportPage.scss';
|
import '../../styles/report/ReportPage.scss';
|
||||||
|
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
import {Route} from "react-router-dom";
|
||||||
import {Col, Nav, NavItem} from 'react-bootstrap';
|
import {Col, Nav, NavItem} from 'react-bootstrap';
|
||||||
import {ReactiveGraph} from 'components/reactive-graph/ReactiveGraph';
|
import {ReactiveGraph} from 'components/reactive-graph/ReactiveGraph';
|
||||||
import {edgeGroupToColor, options} from 'components/map/MapOptions';
|
import {edgeGroupToColor, options} from 'components/map/MapOptions';
|
||||||
|
@ -24,13 +25,22 @@ class ReportPageComponent extends AuthComponent {
|
||||||
zeroTrustReport: {},
|
zeroTrustReport: {},
|
||||||
allMonkeysAreDead: false,
|
allMonkeysAreDead: false,
|
||||||
runStarted: true,
|
runStarted: true,
|
||||||
selectedSection: 'security',
|
selectedSection: ReportPageComponent.selectReport(this.sectionsOrder),
|
||||||
sections: [{key: 'security', title: 'Security report'},
|
sections: [{key: 'security', title: 'Security report'},
|
||||||
{key: 'zeroTrust', title: 'Zero trust report'},
|
{key: 'zeroTrust', title: 'Zero trust report'},
|
||||||
{key: 'attack', title: 'ATT&CK report'}]
|
{key: 'attack', title: 'ATT&CK report'}]
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static selectReport(reports){
|
||||||
|
let url = window.location.href;
|
||||||
|
for (let report_name in reports){
|
||||||
|
if (reports.hasOwnProperty(report_name) && url.endsWith(reports[report_name])){
|
||||||
|
return reports[report_name];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
getReportFromServer(res) {
|
getReportFromServer(res) {
|
||||||
if (res['completed_steps']['run_monkey']) {
|
if (res['completed_steps']['run_monkey']) {
|
||||||
this.authFetch('/api/report/security')
|
this.authFetch('/api/report/security')
|
||||||
|
@ -69,7 +79,8 @@ class ReportPageComponent extends AuthComponent {
|
||||||
ztReport.pillars = res;
|
ztReport.pillars = res;
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
this.setState({zeroTrustReport: ztReport})
|
this.setState({zeroTrustReport: ztReport})
|
||||||
})};
|
})
|
||||||
|
};
|
||||||
|
|
||||||
componentWillUnmount() {
|
componentWillUnmount() {
|
||||||
clearInterval(this.state.ztReportRefreshInterval);
|
clearInterval(this.state.ztReportRefreshInterval);
|
||||||
|
@ -97,14 +108,25 @@ class ReportPageComponent extends AuthComponent {
|
||||||
};
|
};
|
||||||
|
|
||||||
renderNav = () => {
|
renderNav = () => {
|
||||||
return (<Nav bsStyle="tabs" justified
|
return (
|
||||||
activeKey={this.state.selectedSection} onSelect={this.setSelectedSection}
|
<Route render={({history}) => (
|
||||||
|
<Nav bsStyle="tabs" justified
|
||||||
|
activeKey={this.state.selectedSection}
|
||||||
|
onSelect={(key) => {this.setSelectedSection(key); history.push(key)}}
|
||||||
className={"report-nav"}>
|
className={"report-nav"}>
|
||||||
{this.state.sections.map(section => <NavItem key={section.key} eventKey={section.key}>{section.title}</NavItem>)}
|
{this.state.sections.map(section => this.renderNavButton(section))}
|
||||||
</Nav>)
|
</Nav>)}/>)
|
||||||
};
|
};
|
||||||
|
|
||||||
getReportContent(){
|
renderNavButton = (section) => {
|
||||||
|
return (
|
||||||
|
<NavItem key={section.key}
|
||||||
|
eventKey={section.key}
|
||||||
|
onSelect={() => {}}>
|
||||||
|
{section.title}
|
||||||
|
</NavItem>)};
|
||||||
|
|
||||||
|
getReportContent() {
|
||||||
switch(this.state.selectedSection){
|
switch(this.state.selectedSection){
|
||||||
case 'security':
|
case 'security':
|
||||||
return (<SecurityReport report={this.state.securityReport}/>);
|
return (<SecurityReport report={this.state.securityReport}/>);
|
||||||
|
|
|
@ -13,7 +13,7 @@ const columns = [
|
||||||
{
|
{
|
||||||
Header: 'Status', id: 'status',
|
Header: 'Status', id: 'status',
|
||||||
accessor: x => {
|
accessor: x => {
|
||||||
return <StatusLabel status={x.status} size="fa-3x" showText={false}/>;
|
return <StatusLabel status={x.status} size="3x" showText={false}/>;
|
||||||
},
|
},
|
||||||
maxWidth: MAX_WIDTH_STATUS_COLUMN
|
maxWidth: MAX_WIDTH_STATUS_COLUMN
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue