update for issue/pr #862

This commit is contained in:
Jeremy Long
2017-10-13 05:58:56 -04:00
parent 79b7d74387
commit 20ff49f66c
3 changed files with 44 additions and 7 deletions

View File

@@ -66,7 +66,6 @@ import org.owasp.dependencycheck.utils.H2DBLock;
import static org.owasp.dependencycheck.analyzer.AnalysisPhase.*; import static org.owasp.dependencycheck.analyzer.AnalysisPhase.*;
//CSON: AvoidStarImport //CSON: AvoidStarImport
/** /**
* Scans files, directories, etc. for Dependencies. Analyzers are loaded and * Scans files, directories, etc. for Dependencies. Analyzers are loaded and
* used to process the files found by the scan, if a file is encountered and an * used to process the files found by the scan, if a file is encountered and an
@@ -661,8 +660,10 @@ public class Engine implements FileFilter, AutoCloseable {
initializeAnalyzer(analyzer); initializeAnalyzer(analyzer);
} catch (InitializationException ex) { } catch (InitializationException ex) {
exceptions.add(ex); exceptions.add(ex);
if (ex.isFatal()) {
continue; continue;
} }
}
if (analyzer.isEnabled()) { if (analyzer.isEnabled()) {
executeAnalysisTasks(analyzer, exceptions); executeAnalysisTasks(analyzer, exceptions);
@@ -815,11 +816,13 @@ public class Engine implements FileFilter, AutoCloseable {
} catch (InitializationException ex) { } catch (InitializationException ex) {
LOGGER.error("Exception occurred initializing {}.", analyzer.getName()); LOGGER.error("Exception occurred initializing {}.", analyzer.getName());
LOGGER.debug("", ex); LOGGER.debug("", ex);
if (ex.isFatal()) {
try { try {
analyzer.close(); analyzer.close();
} catch (Throwable ex1) { } catch (Throwable ex1) {
LOGGER.trace("", ex1); LOGGER.trace("", ex1);
} }
}
throw ex; throw ex;
} catch (Throwable ex) { } catch (Throwable ex) {
LOGGER.error("Unexpected exception occurred initializing {}.", analyzer.getName()); LOGGER.error("Unexpected exception occurred initializing {}.", analyzer.getName());

View File

@@ -90,7 +90,7 @@ public abstract class AbstractSuppressionAnalyzer extends AbstractAnalyzer {
try { try {
loadSuppressionData(); loadSuppressionData();
} catch (SuppressionParseException ex) { } catch (SuppressionParseException ex) {
throw new InitializationException("Error initializing the suppression analyzer: " + ex.getLocalizedMessage(), ex); throw new InitializationException("Error initializing the suppression analyzer: " + ex.getLocalizedMessage(), ex, true);
} }
} }
} }

View File

@@ -31,6 +31,28 @@ public class InitializationException extends Exception {
* The serial version uid. * The serial version uid.
*/ */
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/**
* Whether or not the exception is fatal.
*/
private boolean fatal = true;
/**
* Get the value of fatal
*
* @return the value of fatal
*/
public boolean isFatal() {
return fatal;
}
/**
* Set the value of fatal
*
* @param fatal new value of fatal
*/
public void setFatal(boolean fatal) {
this.fatal = fatal;
}
/** /**
* Creates a new InitializationException. * Creates a new InitializationException.
@@ -66,4 +88,16 @@ public class InitializationException extends Exception {
public InitializationException(String msg, Throwable ex) { public InitializationException(String msg, Throwable ex) {
super(msg, ex); super(msg, ex);
} }
/**
* Creates a new InitializationException.
*
* @param msg a message for the exception.
* @param ex the cause of the exception.
* @param fatal whether or not the exception is fatal.
*/
public InitializationException(String msg, Throwable ex, boolean fatal) {
super(msg, ex);
this.fatal = fatal;
}
} }