UI: Set stolen_creds issues in state

This commit is contained in:
Ilija Lazoroski 2022-07-18 08:44:38 +02:00
parent 5e1adbb877
commit 07b4956717
1 changed files with 20 additions and 17 deletions

View File

@ -159,7 +159,8 @@ class ReportPageComponent extends AuthComponent {
graph: {nodes: [], edges: []}, graph: {nodes: [], edges: []},
nodeStateList: [], nodeStateList: [],
stolenCredentials: [], stolenCredentials: [],
configuredCredentials: [] configuredCredentials: [],
issues: []
}; };
} }
@ -196,19 +197,11 @@ class ReportPageComponent extends AuthComponent {
componentDidUpdate(prevProps) { componentDidUpdate(prevProps) {
if (this.props.report !== prevProps.report) { 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() { render() {
let content; let content;
@ -381,6 +374,9 @@ class ReportPageComponent extends AuthComponent {
getPotentialSecurityIssuesOverviews() { getPotentialSecurityIssuesOverviews() {
let overviews = []; let overviews = [];
let issues = this.state.report.overview.issues; 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++) { for(let i=0; i < issues.length; i++) {
if (this.isIssuePotentialSecurityIssue(issues[i])) { if (this.isIssuePotentialSecurityIssue(issues[i])) {
@ -422,6 +418,10 @@ class ReportPageComponent extends AuthComponent {
getImmediateThreatCount() { getImmediateThreatCount() {
let threatCount = 0; let threatCount = 0;
let issues = this.state.report.overview.issues; 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++) { for(let i=0; i < issues.length; i++) {
if(this.isIssueImmediateThreat(issues[i])) { if(this.isIssueImmediateThreat(issues[i])) {
@ -441,6 +441,10 @@ class ReportPageComponent extends AuthComponent {
getImmediateThreatsOverviews() { getImmediateThreatsOverviews() {
let overviews = []; let overviews = [];
let issues = this.state.report.overview.issues; 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++) { for(let i=0; i < issues.length; i++) {
if (this.isIssueImmediateThreat(issues[i])) { if (this.isIssueImmediateThreat(issues[i])) {
@ -588,16 +592,15 @@ class ReportPageComponent extends AuthComponent {
return <ul>{issuesDivArray}</ul>; return <ul>{issuesDivArray}</ul>;
}; };
addIssuesToOverviewIssues(report) { addIssuesToOverviewIssues() {
let issues = report.overview.issues; let overview_issues = this.state.issues;
let overview_issues = issues;
if (this.shouldAddStolenCredentialsIssue()) { if (this.shouldAddStolenCredentialsIssue()) {
overview_issues.push('stolen_creds'); overview_issues.push('stolen_creds');
} }
const newOverview = { ...report.overview, issues : overview_issues }; this.setState({
const newReport = { ...report, overview : newOverview }; issues: overview_issues
return newReport; });
} }
shouldAddStolenCredentialsIssue() { shouldAddStolenCredentialsIssue() {