forked from p15670423/monkey
ui: make unsafeItemSelected() a pure function
This commit is contained in:
parent
ff28509d0d
commit
8f32c48964
|
@ -18,6 +18,19 @@ const CONFIG_URL = '/api/configuration/island';
|
|||
export const API_PBA_LINUX = '/api/fileUpload/PBAlinux';
|
||||
export const API_PBA_WINDOWS = '/api/fileUpload/PBAwindows';
|
||||
|
||||
function unsafeItemSelected(options, selectedOptions) {
|
||||
let item_safety = new Map();
|
||||
options.forEach(i => item_safety[i.enum[0]] = i.safe);
|
||||
|
||||
for (let selected of selectedOptions) {
|
||||
if (!item_safety[selected]) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
class ConfigurePageComponent extends AuthComponent {
|
||||
|
||||
constructor(props) {
|
||||
|
@ -122,39 +135,26 @@ class ConfigurePageComponent extends AuthComponent {
|
|||
}
|
||||
|
||||
unsafeExploiterSelected(config) {
|
||||
return this.unsafeItemSelected(
|
||||
return unsafeItemSelected(
|
||||
this.state.schema.definitions.exploiter_classes.anyOf,
|
||||
config.basic.exploiters.exploiter_classes
|
||||
);
|
||||
}
|
||||
|
||||
unsafePostBreachActionSelected(config) {
|
||||
return this.unsafeItemSelected(
|
||||
return unsafeItemSelected(
|
||||
this.state.schema.definitions.post_breach_actions.anyOf,
|
||||
config.monkey.post_breach.post_breach_actions
|
||||
);
|
||||
}
|
||||
|
||||
unsafeSystemInfoCollectorSelected(config) {
|
||||
return this.unsafeItemSelected(
|
||||
return unsafeItemSelected(
|
||||
this.state.schema.definitions.system_info_collector_classes.anyOf,
|
||||
config.monkey.system_info.system_info_collector_classes
|
||||
);
|
||||
}
|
||||
|
||||
unsafeItemSelected(options, selectedOptions) {
|
||||
let item_safety = new Map();
|
||||
options.forEach(i => item_safety[i.enum[0]] = i.safe);
|
||||
|
||||
for (let selected of selectedOptions) {
|
||||
if (!item_safety[selected]) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
matrixSubmit = () => {
|
||||
// Submit attack matrix
|
||||
this.authFetch(ATTACK_URL,
|
||||
|
|
Loading…
Reference in New Issue