From d37fea06d82aacf0ca0647d93bb8dcccbe02e462 Mon Sep 17 00:00:00 2001 From: VakarisZ Date: Wed, 29 Jul 2020 12:49:51 +0300 Subject: [PATCH] Grouped Shell Startup modification PBA outputs data into a single PBA --- .../report-components/security/PostBreach.js | 2 ++ .../security/PostBreachParser.js | 33 +++++++++++++++++++ .../cc/ui/src/styles/report/ReportPage.scss | 2 ++ 3 files changed, 37 insertions(+) create mode 100644 monkey/monkey_island/cc/ui/src/components/report-components/security/PostBreachParser.js 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 cc9ea1c20..4df0c33a1 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 @@ -2,6 +2,7 @@ import React from 'react'; import ReactTable from 'react-table'; import Pluralize from 'pluralize'; import {renderIpAddresses} from "../common/RenderArrays"; +import parsePbaResults from "./PostBreachParser"; let renderMachine = function (data) { return
{data.label} ( {renderIpAddresses(data)} )
@@ -54,6 +55,7 @@ class PostBreachComponent extends React.Component { let pbaMachines = this.props.data.filter(function (value) { return (value.pba_results !== 'None' && value.pba_results.length > 0); }); + pbaMachines = pbaMachines.map(pbaData => parsePbaResults(pbaData)); let defaultPageSize = pbaMachines.length > pageSize ? pageSize : pbaMachines.length; let showPagination = pbaMachines > pageSize; const pbaCount = pbaMachines.reduce((accumulated, pbaMachine) => accumulated+pbaMachine["pba_results"].length, 0); diff --git a/monkey/monkey_island/cc/ui/src/components/report-components/security/PostBreachParser.js b/monkey/monkey_island/cc/ui/src/components/report-components/security/PostBreachParser.js new file mode 100644 index 000000000..39dfecf7e --- /dev/null +++ b/monkey/monkey_island/cc/ui/src/components/report-components/security/PostBreachParser.js @@ -0,0 +1,33 @@ +export default function parsePbaResults(results) { + results.pba_results = aggregateShellStartupPba(results.pba_results); + return results; +} + +const SHELL_STARTUP_NAME = 'Modify shell startup file'; + +function aggregateShellStartupPba(results) { + let isSuccess = false; + let aggregatedPbaResult = undefined; + let successfulOutputs = ''; + let failedOutputs = ''; + + for(let i = 0; i < results.length; i++){ + if(results[i].name === SHELL_STARTUP_NAME && aggregatedPbaResult === undefined){ + aggregatedPbaResult = results[i]; + } + if(results[i].name === SHELL_STARTUP_NAME && results[i].result[1]){ + successfulOutputs += results[i].result[0]; + isSuccess = true; + } + if(results[i].name === SHELL_STARTUP_NAME && ! results[i].result[1]){ + failedOutputs += results[i].result[0]; + } + } + if(aggregatedPbaResult === undefined) return; + + results = results.filter(result => result.name !== SHELL_STARTUP_NAME); + aggregatedPbaResult.result[0] = successfulOutputs + failedOutputs; + aggregatedPbaResult.result[1] = isSuccess; + results.push(aggregatedPbaResult); + return results; +} diff --git a/monkey/monkey_island/cc/ui/src/styles/report/ReportPage.scss b/monkey/monkey_island/cc/ui/src/styles/report/ReportPage.scss index 0c618bd7f..5fb8252fe 100644 --- a/monkey/monkey_island/cc/ui/src/styles/report/ReportPage.scss +++ b/monkey/monkey_island/cc/ui/src/styles/report/ReportPage.scss @@ -60,10 +60,12 @@ .pba-danger { background-color: #ffc7af; + white-space: pre-wrap; } .pba-success { background-color: #afd2a2; + white-space: pre-wrap; } div.report-wrapper {