9: Add additional severity's level
This commit is contained in:
@@ -4,7 +4,6 @@ import com.bartek.esa.analyser.apk.ApkAnalyser;
|
||||
import com.bartek.esa.analyser.source.SourceAnalyser;
|
||||
import com.bartek.esa.cli.model.CliArgsOptions;
|
||||
import com.bartek.esa.cli.parser.CliArgsParser;
|
||||
import com.bartek.esa.core.model.enumeration.Severity;
|
||||
import com.bartek.esa.core.model.object.Issue;
|
||||
import com.bartek.esa.di.DaggerDependencyInjector;
|
||||
import com.bartek.esa.dispatcher.dispatcher.MethodDispatcher;
|
||||
@@ -44,7 +43,7 @@ public class EsaMain {
|
||||
}
|
||||
|
||||
private void exitWithErrorIfAnyIssueIsAnError(Set<Issue> issues) {
|
||||
if(issues.stream().anyMatch(i -> i.getSeverity() == Severity.ERROR)) {
|
||||
if(issues.stream().anyMatch(i -> i.getSeverity().isExitWithError())) {
|
||||
System.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,17 @@
|
||||
package com.bartek.esa.core.model.enumeration;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
public enum Severity {
|
||||
WARNING,
|
||||
ERROR
|
||||
INFO(false),
|
||||
WARNING(false),
|
||||
ERROR(true),
|
||||
VULNERABILITY(true);
|
||||
|
||||
private final boolean exitWithError;
|
||||
|
||||
Severity(boolean exitWithError) {
|
||||
this.exitWithError = exitWithError;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -87,8 +87,10 @@ public class ColorFormatter implements Formatter {
|
||||
|
||||
private Ansi.Color getColorForSeverity(Issue issue) {
|
||||
switch(issue.getSeverity()) {
|
||||
case INFO: return GREEN;
|
||||
case WARNING: return YELLOW;
|
||||
case ERROR: return RED;
|
||||
case ERROR: return MAGENTA;
|
||||
case VULNERABILITY: return RED;
|
||||
}
|
||||
|
||||
return RED;
|
||||
|
||||
Reference in New Issue
Block a user