Island: Pass island mode as a prop from Main.js to child components
This commit is contained in:
parent
f725efd41a
commit
a786428652
|
@ -27,6 +27,7 @@ import {StandardLayoutComponent} from './layouts/StandardLayoutComponent';
|
||||||
import LoadingScreen from './ui-components/LoadingScreen';
|
import LoadingScreen from './ui-components/LoadingScreen';
|
||||||
|
|
||||||
const reportZeroTrustRoute = '/report/zeroTrust';
|
const reportZeroTrustRoute = '/report/zeroTrust';
|
||||||
|
const islandModeRoute = '/api/island-mode'
|
||||||
|
|
||||||
class AppComponent extends AuthComponent {
|
class AppComponent extends AuthComponent {
|
||||||
updateStatus = () => {
|
updateStatus = () => {
|
||||||
|
@ -113,15 +114,26 @@ class AppComponent extends AuthComponent {
|
||||||
infection_done: false,
|
infection_done: false,
|
||||||
report_done: false,
|
report_done: false,
|
||||||
isLoggedIn: undefined,
|
isLoggedIn: undefined,
|
||||||
needsRegistration: undefined
|
needsRegistration: undefined,
|
||||||
|
islandMode: undefined
|
||||||
},
|
},
|
||||||
noAuthLoginAttempted: undefined
|
noAuthLoginAttempted: undefined
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
updateIslandMode() {
|
||||||
|
this.authFetch(islandModeRoute)
|
||||||
|
.then(res => res.json())
|
||||||
|
.then(res => {
|
||||||
|
this.setState({islandMode: res.mode})
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
this.updateStatus();
|
this.updateStatus();
|
||||||
this.interval = setInterval(this.updateStatus, 10000);
|
this.interval = setInterval(this.updateStatus, 10000);
|
||||||
|
this.updateIslandMode()
|
||||||
}
|
}
|
||||||
|
|
||||||
componentWillUnmount() {
|
componentWillUnmount() {
|
||||||
|
@ -147,6 +159,7 @@ class AppComponent extends AuthComponent {
|
||||||
completedSteps={this.state.completedSteps}/>)}
|
completedSteps={this.state.completedSteps}/>)}
|
||||||
{this.renderRoute('/run-monkey',
|
{this.renderRoute('/run-monkey',
|
||||||
<StandardLayoutComponent component={RunMonkeyPage}
|
<StandardLayoutComponent component={RunMonkeyPage}
|
||||||
|
islandMode={this.state.islandMode}
|
||||||
onStatusChange={this.updateStatus}
|
onStatusChange={this.updateStatus}
|
||||||
completedSteps={this.state.completedSteps}/>)}
|
completedSteps={this.state.completedSteps}/>)}
|
||||||
{this.renderRoute('/infection/map',
|
{this.renderRoute('/infection/map',
|
||||||
|
|
|
@ -17,7 +17,7 @@ class RunMonkeyPageComponent extends AuthComponent {
|
||||||
Go ahead and run the monkey!
|
Go ahead and run the monkey!
|
||||||
<i> (Or <Link to="/configure">configure the monkey</Link> to fine tune its behavior)</i>
|
<i> (Or <Link to="/configure">configure the monkey</Link> to fine tune its behavior)</i>
|
||||||
</p>
|
</p>
|
||||||
<RunOptions />
|
<RunOptions islandMode={this.props.islandMode}/>
|
||||||
</Col>
|
</Col>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,6 @@ import AWSRunButton from './RunOnAWS/AWSRunButton';
|
||||||
import CloudOptions from './scoutsuite-setup/CloudOptions';
|
import CloudOptions from './scoutsuite-setup/CloudOptions';
|
||||||
|
|
||||||
const CONFIG_URL = '/api/configuration/island';
|
const CONFIG_URL = '/api/configuration/island';
|
||||||
const MODE_URL = '/api/island-mode'
|
|
||||||
|
|
||||||
function RunOptions(props) {
|
function RunOptions(props) {
|
||||||
|
|
||||||
|
@ -57,22 +56,11 @@ function RunOptions(props) {
|
||||||
return InlineSelection(defaultContents, newProps);
|
return InlineSelection(defaultContents, newProps);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getIslandMode() {
|
function shouldShowScoutsuite(islandMode){
|
||||||
let mode = 'advanced';
|
return islandMode !== 'ransomware';
|
||||||
authComponent.authFetch(MODE_URL)
|
|
||||||
.then(res => res.json())
|
|
||||||
.then(res => {
|
|
||||||
mode = res.mode
|
|
||||||
}
|
|
||||||
);
|
|
||||||
return mode;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function shouldShowScoutsuite(){
|
function defaultContents(props) {
|
||||||
return getIslandMode() === 'advanced';
|
|
||||||
}
|
|
||||||
|
|
||||||
function defaultContents() {
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<RunOnIslandButton title={'From Island'}
|
<RunOnIslandButton title={'From Island'}
|
||||||
|
@ -85,8 +73,8 @@ function RunOptions(props) {
|
||||||
setComponent(LocalManualRunOptions,
|
setComponent(LocalManualRunOptions,
|
||||||
{ips: ips, setComponent: setComponent})
|
{ips: ips, setComponent: setComponent})
|
||||||
}}/>
|
}}/>
|
||||||
{shouldShowScoutsuite() && <AWSRunButton setComponent={setComponent}/> }
|
{shouldShowScoutsuite(props.islandMode) && <AWSRunButton setComponent={setComponent}/> }
|
||||||
{shouldShowScoutsuite() && <NextSelectionButton title={'Cloud security scan'}
|
{shouldShowScoutsuite(props.islandMode) && <NextSelectionButton title={'Cloud security scan'}
|
||||||
description={'Explains how to enable cloud security scan.'}
|
description={'Explains how to enable cloud security scan.'}
|
||||||
icon={faCloud}
|
icon={faCloud}
|
||||||
onButtonClick={() => {
|
onButtonClick={() => {
|
||||||
|
|
Loading…
Reference in New Issue