diff --git a/monkey/monkey_island/cc/services/telemetry/processing/post_breach.py b/monkey/monkey_island/cc/services/telemetry/processing/post_breach.py index 974a696d5..63cdfff48 100644 --- a/monkey/monkey_island/cc/services/telemetry/processing/post_breach.py +++ b/monkey/monkey_island/cc/services/telemetry/processing/post_breach.py @@ -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.models import Monkey 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) +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_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): - mongo.db.monkey.update( - {'guid': telemetry_json['monkey_guid']}, - {'$push': {'pba_results': telemetry_json['data']}}) - post_breach_action_name = telemetry_json["data"]["name"] if post_breach_action_name in POST_BREACH_TELEMETRY_PROCESSING_FUNCS: 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']}}) diff --git a/monkey/monkey_island/cc/ui/src/components/report-components/security/PostBreach.js b/monkey/monkey_island/cc/ui/src/components/report-components/security/PostBreach.js index f49995b27..cc9ea1c20 100644 --- a/monkey/monkey_island/cc/ui/src/components/report-components/security/PostBreach.js +++ b/monkey/monkey_island/cc/ui/src/components/report-components/security/PostBreach.js @@ -23,17 +23,6 @@ const subColumns = [ ]; 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 showPagination = data.length > pageSize; return