9: Add additional severity's level

This commit is contained in:
Bartłomiej Pluta
2019-04-05 09:27:40 +02:00
parent 7358569eab
commit f483961692
3 changed files with 17 additions and 5 deletions

View File

@@ -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);
}
}

View File

@@ -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;
}
}

View File

@@ -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;