mythx-report-helper
Advanced tools
Comparing version 1.1.3 to 1.1.4
@@ -8,5 +8,6 @@ "use strict"; | ||
class Report { | ||
constructor(issues, input) { | ||
constructor(issues, input, filter) { | ||
this.originalIssues = issues; | ||
this.input = input; | ||
this.filter = filter; | ||
this.sourceFilesNames = []; | ||
@@ -22,3 +23,27 @@ this.sortedFileNames = []; | ||
this.issuesWithMetrics = this.originalIssues && metrics_1.processMetrics(this.originalIssues); | ||
this.processedIssues && this.applyFilters(); | ||
} | ||
updateFilter(newFilter) { | ||
this.filter = newFilter; | ||
this.processedIssues && this.applyFilters(); | ||
this.originalIssues && this.input && this.indexVulnerabilitiesByLineNumber(); | ||
} | ||
getIssuesToDisplay() { | ||
return this.filteredIssues ? this.filteredIssues : this.processedIssues; | ||
} | ||
applyFilters() { | ||
let filteredIssues = this.processedIssues; | ||
if (!this.filter) { | ||
return; | ||
} | ||
if (!this.filter.displayIgnored) { | ||
filteredIssues = filteredIssues.filter((issue) => !issue.ignored); | ||
} | ||
if (this.filter.severity) { | ||
filteredIssues = filteredIssues.filter((issue) => { | ||
return this.filter.severity.indexOf(issue.severity.toLowerCase()) > -1; | ||
}); | ||
} | ||
this.filteredIssues = filteredIssues; | ||
} | ||
setupSourceFiles() { | ||
@@ -72,3 +97,6 @@ if (this.input.mainSource) { | ||
} | ||
logs = logs && logs.filter(log => log.length !== 0).flat(1); | ||
logs = logs && logs.length && logs.filter(log => log.length !== 0); | ||
if (logs.flat) { | ||
logs = logs.flat(1); | ||
} | ||
this.logs = logs; | ||
@@ -134,3 +162,3 @@ } | ||
indexVulnerabilitiesByLineNumber() { | ||
const { processedIssues, sourceFilesNames, sourceFiles } = this; | ||
const { processedIssues, filteredIssues, sourceFilesNames, sourceFiles } = this; | ||
sourceFilesNames.map((name) => { | ||
@@ -148,3 +176,4 @@ const { source, sourceFileAvailable } = sourceFiles[name]; | ||
} | ||
const issuesForFile = processedIssues.filter((issue) => { | ||
const targetIssues = filteredIssues || processedIssues; | ||
const issuesForFile = targetIssues.filter((issue) => { | ||
if (issue.isTypeSolidity && issue.hasDecodedLocation && issue.sourceCode) { | ||
@@ -151,0 +180,0 @@ return issue.sourceCode.name === name; |
{ | ||
"name": "mythx-report-helper", | ||
"version": "1.1.3", | ||
"version": "1.1.4", | ||
"description": "TS helper to manage mythx reports", | ||
@@ -5,0 +5,0 @@ "main": "./build/src/index.js", |
Sorry, the diff of this file is not supported yet
46008
408