From 07b495671704651b1ff4ebdb04ec6cea79e52a46 Mon Sep 17 00:00:00 2001 From: Ilija Lazoroski Date: Mon, 18 Jul 2022 08:44:38 +0200 Subject: [PATCH] UI: Set stolen_creds issues in state --- .../report-components/SecurityReport.js | 37 ++++++++++--------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/monkey/monkey_island/cc/ui/src/components/report-components/SecurityReport.js b/monkey/monkey_island/cc/ui/src/components/report-components/SecurityReport.js index 61f5dfc60..a98efb3a0 100644 --- a/monkey/monkey_island/cc/ui/src/components/report-components/SecurityReport.js +++ b/monkey/monkey_island/cc/ui/src/components/report-components/SecurityReport.js @@ -159,7 +159,8 @@ class ReportPageComponent extends AuthComponent { graph: {nodes: [], edges: []}, nodeStateList: [], stolenCredentials: [], - configuredCredentials: [] + configuredCredentials: [], + issues: [] }; } @@ -196,19 +197,11 @@ class ReportPageComponent extends AuthComponent { componentDidUpdate(prevProps) { if (this.props.report !== prevProps.report) { - this.updateReport(this.props.report); + this.setState({report: this.props.report}); + this.addIssuesToOverviewIssues(); } } - updateReport(report) { - let newReport = this.addIssuesToOverviewIssues(report); - - this.setState({ - report: newReport - }) - } - - render() { let content; @@ -381,6 +374,9 @@ class ReportPageComponent extends AuthComponent { getPotentialSecurityIssuesOverviews() { let overviews = []; let issues = this.state.report.overview.issues; + let state_issues = this.state.issues; + issues.push(...state_issues); + issues = [...new Set(issues)]; for(let i=0; i < issues.length; i++) { if (this.isIssuePotentialSecurityIssue(issues[i])) { @@ -422,6 +418,10 @@ class ReportPageComponent extends AuthComponent { getImmediateThreatCount() { let threatCount = 0; let issues = this.state.report.overview.issues; + let state_issues = this.state.issues; + + issues.push(...state_issues); + issues = [...new Set(issues)]; for(let i=0; i < issues.length; i++) { if(this.isIssueImmediateThreat(issues[i])) { @@ -441,6 +441,10 @@ class ReportPageComponent extends AuthComponent { getImmediateThreatsOverviews() { let overviews = []; let issues = this.state.report.overview.issues; + let state_issues = this.state.issues; + + issues.push(...state_issues); + issues = [...new Set(issues)]; for(let i=0; i < issues.length; i++) { if (this.isIssueImmediateThreat(issues[i])) { @@ -588,16 +592,15 @@ class ReportPageComponent extends AuthComponent { return ; }; - addIssuesToOverviewIssues(report) { - let issues = report.overview.issues; - let overview_issues = issues; + addIssuesToOverviewIssues() { + let overview_issues = this.state.issues; if (this.shouldAddStolenCredentialsIssue()) { overview_issues.push('stolen_creds'); } - const newOverview = { ...report.overview, issues : overview_issues }; - const newReport = { ...report, overview : newOverview }; - return newReport; + this.setState({ + issues: overview_issues + }); } shouldAddStolenCredentialsIssue() {