mirror of
https://github.com/ysoftdevs/DependencyCheck.git
synced 2026-01-18 17:47:05 +01:00
Fixed the creation of the GrokAssembly.exe temp file and the cleanup of the temp config file.
This commit is contained in:
@@ -73,6 +73,10 @@ public class AssemblyAnalyzer extends AbstractFileTypeAnalyzer {
|
||||
* The temp value for GrokAssembly.exe
|
||||
*/
|
||||
private File grokAssemblyExe = null;
|
||||
/**
|
||||
* The temp value for GrokAssembly.exe.config
|
||||
*/
|
||||
private File grokAssemblyConfig = null;
|
||||
/**
|
||||
* Logger
|
||||
*/
|
||||
@@ -201,22 +205,24 @@ public class AssemblyAnalyzer extends AbstractFileTypeAnalyzer {
|
||||
@Override
|
||||
public void initializeFileTypeAnalyzer() throws InitializationException {
|
||||
final File tempFile;
|
||||
final String cfg;
|
||||
final File cfgFile;
|
||||
try {
|
||||
tempFile = File.createTempFile("GKA", ".exe", Settings.getTempDirectory());
|
||||
cfg = tempFile.getPath() + ".config";
|
||||
cfgFile = new File(tempFile.getPath() + ".config");
|
||||
} catch (IOException ex) {
|
||||
setEnabled(false);
|
||||
throw new InitializationException("Unable to create temporary file for the assembly analyzer", ex);
|
||||
}
|
||||
try (FileOutputStream fos = new FileOutputStream(tempFile);
|
||||
InputStream is = FileUtils.getResourceAsStream("GrokAssembly.exe");
|
||||
FileOutputStream fosCfg = new FileOutputStream(cfg);
|
||||
InputStream isCfg = FileUtils.getResourceAsStream("GrokAssembly.exe.config")) {
|
||||
InputStream is = FileUtils.getResourceAsStream("GrokAssembly.exe");
|
||||
FileOutputStream fosCfg = new FileOutputStream(cfgFile);
|
||||
InputStream isCfg = FileUtils.getResourceAsStream("GrokAssembly.exe.config")) {
|
||||
IOUtils.copy(is, fos);
|
||||
grokAssemblyExe = tempFile;
|
||||
LOGGER.debug("Extracted GrokAssembly.exe to {}", grokAssemblyExe.getPath());
|
||||
IOUtils.copy(isCfg, fosCfg);
|
||||
LOGGER.debug("Extracted GrokAssembly.exe.config to {}", cfg);
|
||||
grokAssemblyConfig = cfgFile;
|
||||
LOGGER.debug("Extracted GrokAssembly.exe.config to {}", cfgFile);
|
||||
} catch (IOException ioe) {
|
||||
this.setEnabled(false);
|
||||
LOGGER.warn("Could not extract GrokAssembly.exe: {}", ioe.getMessage());
|
||||
@@ -287,6 +293,15 @@ public class AssemblyAnalyzer extends AbstractFileTypeAnalyzer {
|
||||
LOGGER.debug("Can't delete temporary GrokAssembly.exe");
|
||||
grokAssemblyExe.deleteOnExit();
|
||||
}
|
||||
try {
|
||||
if (grokAssemblyConfig != null && !grokAssemblyConfig.delete()) {
|
||||
LOGGER.debug("Unable to delete temporary GrokAssembly.exe.config; attempting delete on exit");
|
||||
grokAssemblyConfig.deleteOnExit();
|
||||
}
|
||||
} catch (SecurityException se) {
|
||||
LOGGER.debug("Can't delete temporary GrokAssembly.exe.config");
|
||||
grokAssemblyConfig.deleteOnExit();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user