From 85b5a156fc32b6ee932f2260b385fad198c254a6 Mon Sep 17 00:00:00 2001 From: Shay Nehmad Date: Tue, 12 May 2020 10:16:04 +0300 Subject: [PATCH] Fixed code review comments - JS linting and readability --- .../security/BreachedServers.js | 6 +++--- .../report-components/security/PostBreach.js | 10 +++++----- .../security/ScannedServers.js | 17 ++++++++++------- 3 files changed, 18 insertions(+), 15 deletions(-) diff --git a/monkey/monkey_island/cc/ui/src/components/report-components/security/BreachedServers.js b/monkey/monkey_island/cc/ui/src/components/report-components/security/BreachedServers.js index 1b2efcd06..3ea23a075 100644 --- a/monkey/monkey_island/cc/ui/src/components/report-components/security/BreachedServers.js +++ b/monkey/monkey_island/cc/ui/src/components/report-components/security/BreachedServers.js @@ -1,6 +1,6 @@ import React from 'react'; -import ReactTable from 'react-table' -import Pluralize from "pluralize"; +import ReactTable from 'react-table'; +import Pluralize from 'pluralize'; let renderArray = function (val) { return
{val.map(x =>
{x}
)}
; @@ -38,7 +38,7 @@ class BreachedServersComponent extends React.Component { <>

The Monkey successfully breached {this.props.data.length} {Pluralize('machines', this.props.data.length)}: + className="label label-danger">{this.props.data.length} {Pluralize('machine', this.props.data.length)}:

{val.map(x => {x})}; @@ -63,13 +63,13 @@ class PostBreachComponent extends React.Component { }); let defaultPageSize = pbaMachines.length > pageSize ? pageSize : pbaMachines.length; let showPagination = pbaMachines > pageSize; - const howManyPBAs = pbaMachines.reduce((accumulated, pbaMachine) => accumulated+pbaMachine["pba_results"].length,0) + const pbaCount = pbaMachines.reduce((accumulated, pbaMachine) => accumulated+pbaMachine["pba_results"].length, 0); return ( <>

The Monkey performed {howManyPBAs} post-breach {Pluralize('actions', howManyPBAs)} on {pbaMachines.length} {Pluralize('machines', pbaMachines.length)}: + className="label label-danger">{pbaCount} post-breach {Pluralize('action', pbaCount)} on {pbaMachines.length} {Pluralize('machine', pbaMachines.length)}:

{val.map(x =>
{x}
)}
; @@ -37,16 +37,19 @@ class ScannedServersComponent extends React.Component { let defaultPageSize = this.props.data.length > pageSize ? pageSize : this.props.data.length; let showPagination = this.props.data.length > pageSize; - const howManyScannedMachines = this.props.data.length; + const scannedMachinesCount = this.props.data.length; const reducerFromScannedServerToServicesAmount = (accumulated, scannedServer) => accumulated + scannedServer["services"].length; - const howManyScannedServices = this.props.data.reduce(reducerFromScannedServerToServicesAmount, 0); + const scannedServicesAmount = this.props.data.reduce(reducerFromScannedServerToServicesAmount, 0); return ( <>

- The Monkey discovered {howManyScannedServices} open {Pluralize('services', howManyScannedServices)} on {howManyScannedMachines} {Pluralize('machines', howManyScannedMachines)}: + The Monkey discovered + {scannedServicesAmount} + open {Pluralize('service', scannedServicesAmount)} + on + {scannedMachinesCount} + {Pluralize('machine', scannedMachinesCount)}: