From dbf56b5531711ac005161b77cc11eb3e18478910 Mon Sep 17 00:00:00 2001 From: VakarisZ Date: Thu, 7 Mar 2019 12:44:15 +0200 Subject: [PATCH] Improved display of post breach actions --- .../report-components/PostBreach.js | 48 ++++++++++++------- 1 file changed, 32 insertions(+), 16 deletions(-) diff --git a/monkey/monkey_island/cc/ui/src/components/report-components/PostBreach.js b/monkey/monkey_island/cc/ui/src/components/report-components/PostBreach.js index b6e36f902..5790e26e5 100644 --- a/monkey/monkey_island/cc/ui/src/components/report-components/PostBreach.js +++ b/monkey/monkey_island/cc/ui/src/components/report-components/PostBreach.js @@ -2,30 +2,39 @@ import React from 'react'; import ReactTable from 'react-table' let renderArray = function(val) { - return
{val.map(x =>
{x}
)}
; + return {val.map(x => {x})}; }; let renderIpAddresses = function (val) { - return
{renderArray(val.ip_addresses)} {(val.domain_name ? " (".concat(val.domain_name, ")") : "")}
; + return {renderArray(val.ip_addresses)} {(val.domain_name ? " (".concat(val.domain_name, ")") : "")} ; }; -let renderPostBreach = function (machine, pbaList) { - if (pbaList.length === 0){ - return - } else { - return
Machine: {machine.label}
- {pbaList.map(x =>
Name: {x.name}
- Command: {x.command}
- Output: {x.output}
)} -
; - } +let renderMachine = function (data) { + return
{data.label} ( {renderIpAddresses(data)} )
+}; + +const subColumns = [ + {id: 'pba_name', Header: "Name", accessor: x => x.name, style: { 'white-space': 'unset' }}, + {id: 'pba_output', Header: "Output", accessor: x => x.output, style: { 'white-space': 'unset' }} +]; + +let renderDetails = function (data) { + let defaultPageSize = data.length > pageSize ? pageSize : data.length; + let showPagination = data.length > pageSize; + return }; const columns = [ { Header: 'Post breach actions', columns: [ - {id: 'post_breach_actions', accessor: x => renderPostBreach(x, x.pba_results)} + {id: 'pba_machine', Header:'Machine', accessor: x => renderMachine(x)} ] } ]; @@ -38,17 +47,24 @@ class PostBreachComponent extends React.Component { } render() { - let defaultPageSize = this.props.data.length > pageSize ? pageSize : this.props.data.length; - let showPagination = this.props.data.length > pageSize; + let pbaMachines = this.props.data.filter(function(value, index, arr){ + return ( value.pba_results !== "None" && value.pba_results.length); + }); + let defaultPageSize = pbaMachines.length > pageSize ? pageSize : pbaMachines.length; + let showPagination = pbaMachines > pageSize; return (
{ + return renderDetails(row.original.pba_results); + }} />
+ ); } }