forked from p15670423/monkey
Merge pull request #1323 from guardicore/ransomware-show-relevant-configuration-tabs
Display relevant configuration tabs in ransomware mode
This commit is contained in:
commit
e241d46263
|
@ -155,6 +155,7 @@ class AppComponent extends AuthComponent {
|
||||||
true)}
|
true)}
|
||||||
{this.renderRoute('/configure',
|
{this.renderRoute('/configure',
|
||||||
<StandardLayoutComponent component={ConfigurePage}
|
<StandardLayoutComponent component={ConfigurePage}
|
||||||
|
islandMode={this.state.islandMode}
|
||||||
onStatusChange={this.updateStatus}
|
onStatusChange={this.updateStatus}
|
||||||
completedSteps={this.state.completedSteps}/>)}
|
completedSteps={this.state.completedSteps}/>)}
|
||||||
{this.renderRoute('/run-monkey',
|
{this.renderRoute('/run-monkey',
|
||||||
|
|
|
@ -0,0 +1,30 @@
|
||||||
|
const CONFIGURATION_TABS = {
|
||||||
|
ATTACK: 'attack',
|
||||||
|
BASIC: 'basic',
|
||||||
|
BASIC_NETWORK: 'basic_network',
|
||||||
|
RANSOMWARE: 'ransomware',
|
||||||
|
MONKEY: 'monkey',
|
||||||
|
INTERNAL: 'internal'
|
||||||
|
};
|
||||||
|
|
||||||
|
const advancedModeConfigTabs = [
|
||||||
|
CONFIGURATION_TABS.ATTACK,
|
||||||
|
CONFIGURATION_TABS.BASIC,
|
||||||
|
CONFIGURATION_TABS.BASIC_NETWORK,
|
||||||
|
CONFIGURATION_TABS.RANSOMWARE,
|
||||||
|
CONFIGURATION_TABS.MONKEY,
|
||||||
|
CONFIGURATION_TABS.INTERNAL
|
||||||
|
];
|
||||||
|
|
||||||
|
const ransomwareModeConfigTabs = [
|
||||||
|
CONFIGURATION_TABS.BASIC,
|
||||||
|
CONFIGURATION_TABS.BASIC_NETWORK,
|
||||||
|
CONFIGURATION_TABS.RANSOMWARE
|
||||||
|
];
|
||||||
|
|
||||||
|
const CONFIGURATION_TABS_PER_MODE = {
|
||||||
|
'advanced': advancedModeConfigTabs,
|
||||||
|
'ransomware': ransomwareModeConfigTabs
|
||||||
|
};
|
||||||
|
|
||||||
|
export default CONFIGURATION_TABS_PER_MODE;
|
|
@ -18,6 +18,7 @@ import ConfigExportModal from '../configuration-components/ExportConfigModal';
|
||||||
import ConfigImportModal from '../configuration-components/ImportConfigModal';
|
import ConfigImportModal from '../configuration-components/ImportConfigModal';
|
||||||
import applyUiSchemaManipulators from '../configuration-components/UISchemaManipulators.tsx';
|
import applyUiSchemaManipulators from '../configuration-components/UISchemaManipulators.tsx';
|
||||||
import HtmlFieldDescription from '../configuration-components/HtmlFieldDescription.js';
|
import HtmlFieldDescription from '../configuration-components/HtmlFieldDescription.js';
|
||||||
|
import CONFIGURATION_TABS_PER_MODE from '../configuration-components/ConfigurationTabs.js';
|
||||||
|
|
||||||
const ATTACK_URL = '/api/attack';
|
const ATTACK_URL = '/api/attack';
|
||||||
const CONFIG_URL = '/api/configuration/island';
|
const CONFIG_URL = '/api/configuration/island';
|
||||||
|
@ -28,10 +29,9 @@ class ConfigurePageComponent extends AuthComponent {
|
||||||
|
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
this.currentSection = 'attack';
|
|
||||||
this.initialConfig = {};
|
this.initialConfig = {};
|
||||||
this.initialAttackConfig = {};
|
this.initialAttackConfig = {};
|
||||||
this.sectionsOrder = ['attack', 'basic', 'basic_network', 'ransomware', 'monkey', 'internal'];
|
this.currentSection = this.getSectionsOrder()[0];
|
||||||
|
|
||||||
this.state = {
|
this.state = {
|
||||||
attackConfig: {},
|
attackConfig: {},
|
||||||
|
@ -41,7 +41,7 @@ class ConfigurePageComponent extends AuthComponent {
|
||||||
lastAction: 'none',
|
lastAction: 'none',
|
||||||
schema: {},
|
schema: {},
|
||||||
sections: [],
|
sections: [],
|
||||||
selectedSection: 'attack',
|
selectedSection: this.currentSection,
|
||||||
showAttackAlert: false,
|
showAttackAlert: false,
|
||||||
showUnsafeOptionsConfirmation: false,
|
showUnsafeOptionsConfirmation: false,
|
||||||
showUnsafeAttackOptionsWarning: false,
|
showUnsafeAttackOptionsWarning: false,
|
||||||
|
@ -50,6 +50,18 @@ class ConfigurePageComponent extends AuthComponent {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
componentDidUpdate() {
|
||||||
|
if (!this.getSectionsOrder().includes(this.currentSection)) {
|
||||||
|
this.currentSection = this.getSectionsOrder()[0]
|
||||||
|
this.setState({selectedSection: this.currentSection})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
getSectionsOrder() {
|
||||||
|
let islandMode = this.props.islandMode ? this.props.islandMode : 'advanced'
|
||||||
|
return CONFIGURATION_TABS_PER_MODE[islandMode];
|
||||||
|
}
|
||||||
|
|
||||||
setInitialConfig(config) {
|
setInitialConfig(config) {
|
||||||
// Sets a reference to know if config was changed
|
// Sets a reference to know if config was changed
|
||||||
this.initialConfig = JSON.parse(JSON.stringify(config));
|
this.initialConfig = JSON.parse(JSON.stringify(config));
|
||||||
|
@ -62,6 +74,7 @@ class ConfigurePageComponent extends AuthComponent {
|
||||||
|
|
||||||
componentDidMount = () => {
|
componentDidMount = () => {
|
||||||
let urls = [CONFIG_URL, ATTACK_URL];
|
let urls = [CONFIG_URL, ATTACK_URL];
|
||||||
|
// ??? Why fetch config here and not in `render()`?
|
||||||
Promise.all(urls.map(url => this.authFetch(url).then(res => res.json())))
|
Promise.all(urls.map(url => this.authFetch(url).then(res => res.json())))
|
||||||
.then(data => {
|
.then(data => {
|
||||||
let sections = [];
|
let sections = [];
|
||||||
|
@ -69,7 +82,7 @@ class ConfigurePageComponent extends AuthComponent {
|
||||||
let monkeyConfig = data[0];
|
let monkeyConfig = data[0];
|
||||||
this.setInitialConfig(monkeyConfig.configuration);
|
this.setInitialConfig(monkeyConfig.configuration);
|
||||||
this.setInitialAttackConfig(attackConfig.configuration);
|
this.setInitialAttackConfig(attackConfig.configuration);
|
||||||
for (let sectionKey of this.sectionsOrder) {
|
for (let sectionKey of this.getSectionsOrder()) {
|
||||||
if (sectionKey === 'attack') {
|
if (sectionKey === 'attack') {
|
||||||
sections.push({key: sectionKey, title: 'ATT&CK'})
|
sections.push({key: sectionKey, title: 'ATT&CK'})
|
||||||
} else {
|
} else {
|
||||||
|
@ -83,8 +96,7 @@ class ConfigurePageComponent extends AuthComponent {
|
||||||
schema: monkeyConfig.schema,
|
schema: monkeyConfig.schema,
|
||||||
configuration: monkeyConfig.configuration,
|
configuration: monkeyConfig.configuration,
|
||||||
attackConfig: attackConfig.configuration,
|
attackConfig: attackConfig.configuration,
|
||||||
sections: sections,
|
sections: sections
|
||||||
selectedSection: 'attack'
|
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
@ -479,7 +491,7 @@ class ConfigurePageComponent extends AuthComponent {
|
||||||
let content = '';
|
let content = '';
|
||||||
if (this.state.selectedSection === 'attack' && Object.entries(this.state.attackConfig).length !== 0) {
|
if (this.state.selectedSection === 'attack' && Object.entries(this.state.attackConfig).length !== 0) {
|
||||||
content = this.renderMatrix()
|
content = this.renderMatrix()
|
||||||
} else if (this.state.selectedSection !== 'attack') {
|
} else if (this.state.selectedSection !== 'attack' && Object.entries(this.state.configuration).length !== 0) {
|
||||||
content = this.renderConfigContent(displayedSchema)
|
content = this.renderConfigContent(displayedSchema)
|
||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
|
|
Loading…
Reference in New Issue