Grouped Shell Startup modification PBA outputs data into a single PBA
This commit is contained in:
parent
e6c93056cc
commit
d37fea06d8
|
@ -2,6 +2,7 @@ import React from 'react';
|
||||||
import ReactTable from 'react-table';
|
import ReactTable from 'react-table';
|
||||||
import Pluralize from 'pluralize';
|
import Pluralize from 'pluralize';
|
||||||
import {renderIpAddresses} from "../common/RenderArrays";
|
import {renderIpAddresses} from "../common/RenderArrays";
|
||||||
|
import parsePbaResults from "./PostBreachParser";
|
||||||
|
|
||||||
let renderMachine = function (data) {
|
let renderMachine = function (data) {
|
||||||
return <div>{data.label} ( {renderIpAddresses(data)} )</div>
|
return <div>{data.label} ( {renderIpAddresses(data)} )</div>
|
||||||
|
@ -54,6 +55,7 @@ class PostBreachComponent extends React.Component {
|
||||||
let pbaMachines = this.props.data.filter(function (value) {
|
let pbaMachines = this.props.data.filter(function (value) {
|
||||||
return (value.pba_results !== 'None' && value.pba_results.length > 0);
|
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 defaultPageSize = pbaMachines.length > pageSize ? pageSize : pbaMachines.length;
|
||||||
let showPagination = pbaMachines > pageSize;
|
let showPagination = pbaMachines > pageSize;
|
||||||
const pbaCount = pbaMachines.reduce((accumulated, pbaMachine) => accumulated+pbaMachine["pba_results"].length, 0);
|
const pbaCount = pbaMachines.reduce((accumulated, pbaMachine) => accumulated+pbaMachine["pba_results"].length, 0);
|
||||||
|
|
|
@ -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;
|
||||||
|
}
|
|
@ -60,10 +60,12 @@
|
||||||
|
|
||||||
.pba-danger {
|
.pba-danger {
|
||||||
background-color: #ffc7af;
|
background-color: #ffc7af;
|
||||||
|
white-space: pre-wrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
.pba-success {
|
.pba-success {
|
||||||
background-color: #afd2a2;
|
background-color: #afd2a2;
|
||||||
|
white-space: pre-wrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
div.report-wrapper {
|
div.report-wrapper {
|
||||||
|
|
Loading…
Reference in New Issue