use of org.owasp.dependencycheck.Engine in project dependency-check-plugin by jenkinsci.
the class DependencyCheckExecutor method call.
/**
* Performs a DependencyCheck analysis build.
*
* @return a boolean value indicating if the build was successful or not. A
* successful build is not determined by the ability to analyze
* dependencies, rather, simply to determine if errors were encountered
* during the execution.
*/
public Boolean call() throws IOException {
if (getJavaVersion() <= 1.6) {
log(Messages.Failure_Java_Version());
return false;
}
log(Messages.Executor_Display_Options());
log(options.toString());
if (!prepareDirectories()) {
return false;
}
Engine engine = null;
try {
engine = executeDependencyCheck();
if (options.isUpdateOnly()) {
return true;
} else {
return generateExternalReports(engine);
}
} catch (DatabaseException ex) {
log(Messages.Failure_Database_Connect());
log(ex.getMessage());
} catch (UpdateException ex) {
log(Messages.Failure_Database_Update());
} catch (ExceptionCollection ec) {
log(Messages.Failure_Collection());
for (Throwable t : ec.getExceptions()) {
log("Exception Caught: " + t.getClass().getCanonicalName());
if (t.getCause() != null && t.getCause().getMessage() != null) {
log("Cause: " + t.getCause().getMessage());
}
log("Message: " + t.getMessage());
log(ExceptionUtils.getStackTrace(t));
}
} finally {
settings.cleanup(true);
if (engine != null) {
engine.close();
}
}
return false;
}
use of org.owasp.dependencycheck.Engine in project dependency-check-plugin by jenkinsci.
the class DependencyCheckExecutor method executeDependencyCheck.
/**
* Executes the Dependency-Check on the dependent libraries.
*
* @return the Engine used to scan the dependencies.
*/
private Engine executeDependencyCheck() throws DatabaseException, UpdateException, ExceptionCollection {
populateSettings();
Engine engine;
if (classLoader != null) {
engine = new Engine(classLoader, settings);
} else {
engine = new Engine(settings);
}
if (options.isUpdateOnly()) {
log(Messages.Executor_Update_Only());
engine.doUpdates();
} else {
for (String scanPath : options.getScanPath()) {
if (new File(scanPath).exists()) {
log(Messages.Executor_Scanning() + " " + scanPath);
engine.scan(scanPath);
} else {
// Scan path does not exist. Check for Ant style pattern sets.
final File baseDir = new File(options.getWorkspace());
// Remove the workspace path from the scan path so FileSet can assume
// the specified path is a patternset that defines includes.
final String includes = scanPath.replace(options.getWorkspace() + File.separator, "");
final FileSet fileSet = Util.createFileSet(baseDir, includes, null);
final Iterator filePathIter = fileSet.iterator();
while (filePathIter.hasNext()) {
final FilePath foundFilePath = new FilePath(new FilePath(baseDir), filePathIter.next().toString());
log(Messages.Executor_Scanning() + " " + foundFilePath.getRemote());
engine.scan(foundFilePath.getRemote());
}
}
}
log(Messages.Executor_Analyzing_Dependencies());
engine.analyzeDependencies();
}
return engine;
}
Aggregations