forked from p15670423/monkey
Move data modification for PBA from frontend to backend
This commit is contained in:
parent
a39a0c2ce6
commit
dec7d9021f
|
@ -1,4 +1,8 @@
|
||||||
from common.data.post_breach_consts import POST_BREACH_COMMUNICATE_AS_NEW_USER
|
import copy
|
||||||
|
|
||||||
|
from common.data.post_breach_consts import (
|
||||||
|
POST_BREACH_COMMUNICATE_AS_NEW_USER,
|
||||||
|
POST_BREACH_SHELL_STARTUP_FILE_MODIFICATION)
|
||||||
from monkey_island.cc.database import mongo
|
from monkey_island.cc.database import mongo
|
||||||
from monkey_island.cc.models import Monkey
|
from monkey_island.cc.models import Monkey
|
||||||
from monkey_island.cc.services.telemetry.zero_trust_tests.communicate_as_new_user import \
|
from monkey_island.cc.services.telemetry.zero_trust_tests.communicate_as_new_user import \
|
||||||
|
@ -12,16 +16,32 @@ def process_communicate_as_new_user_telemetry(telemetry_json):
|
||||||
test_new_user_communication(current_monkey, success, message)
|
test_new_user_communication(current_monkey, success, message)
|
||||||
|
|
||||||
|
|
||||||
|
def process_shell_startup_file_modification_telemetry(telemetry_json):
|
||||||
|
modified_data = []
|
||||||
|
for result in telemetry_json['data']['result']:
|
||||||
|
temp = copy.deepcopy(telemetry_json['data'])
|
||||||
|
temp['result'] = result
|
||||||
|
modified_data.append(temp)
|
||||||
|
telemetry_json['data'] = modified_data
|
||||||
|
|
||||||
|
|
||||||
POST_BREACH_TELEMETRY_PROCESSING_FUNCS = {
|
POST_BREACH_TELEMETRY_PROCESSING_FUNCS = {
|
||||||
POST_BREACH_COMMUNICATE_AS_NEW_USER: process_communicate_as_new_user_telemetry,
|
POST_BREACH_COMMUNICATE_AS_NEW_USER: process_communicate_as_new_user_telemetry,
|
||||||
|
POST_BREACH_SHELL_STARTUP_FILE_MODIFICATION: process_shell_startup_file_modification_telemetry,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def process_post_breach_telemetry(telemetry_json):
|
def process_post_breach_telemetry(telemetry_json):
|
||||||
mongo.db.monkey.update(
|
|
||||||
{'guid': telemetry_json['monkey_guid']},
|
|
||||||
{'$push': {'pba_results': telemetry_json['data']}})
|
|
||||||
|
|
||||||
post_breach_action_name = telemetry_json["data"]["name"]
|
post_breach_action_name = telemetry_json["data"]["name"]
|
||||||
if post_breach_action_name in POST_BREACH_TELEMETRY_PROCESSING_FUNCS:
|
if post_breach_action_name in POST_BREACH_TELEMETRY_PROCESSING_FUNCS:
|
||||||
POST_BREACH_TELEMETRY_PROCESSING_FUNCS[post_breach_action_name](telemetry_json)
|
POST_BREACH_TELEMETRY_PROCESSING_FUNCS[post_breach_action_name](telemetry_json)
|
||||||
|
|
||||||
|
if type(telemetry_json['data']) is list:
|
||||||
|
for pba_data in telemetry_json['data']:
|
||||||
|
mongo.db.monkey.update(
|
||||||
|
{'guid': telemetry_json['monkey_guid']},
|
||||||
|
{'$push': {'pba_results': pba_data}})
|
||||||
|
else:
|
||||||
|
mongo.db.monkey.update(
|
||||||
|
{'guid': telemetry_json['monkey_guid']},
|
||||||
|
{'$push': {'pba_results': telemetry_json['data']}})
|
||||||
|
|
|
@ -23,17 +23,6 @@ const subColumns = [
|
||||||
];
|
];
|
||||||
|
|
||||||
let renderDetails = function (data) {
|
let renderDetails = function (data) {
|
||||||
data.forEach(pba => {
|
|
||||||
if (typeof pba['result'][0] === "object") { // if `result` has more than one entry
|
|
||||||
let results = pba['result'];
|
|
||||||
let details = data.splice(data.indexOf(pba), 1); // remove that pba from `data`
|
|
||||||
results.forEach(result => { // add back those results to `data` as individual pba entries
|
|
||||||
let tempDetails = JSON.parse(JSON.stringify(details));
|
|
||||||
tempDetails[0]['result'] = result;
|
|
||||||
data.push(tempDetails[0]);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
let defaultPageSize = data.length > pageSize ? pageSize : data.length;
|
let defaultPageSize = data.length > pageSize ? pageSize : data.length;
|
||||||
let showPagination = data.length > pageSize;
|
let showPagination = data.length > pageSize;
|
||||||
return <ReactTable
|
return <ReactTable
|
||||||
|
|
Loading…
Reference in New Issue