Merge pull request #6324 from kellykelly3/6881-process-builder-double-quote

6881 & 6798 - Added double quotes around process builder paths.
This commit is contained in:
Richard Cordovano 2020-09-24 12:24:42 -04:00 committed by GitHub
commit dce2fa42f8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 33 additions and 35 deletions

View File

@ -193,7 +193,7 @@ public class LocalFilesDSProcessor implements DataSourceProcessor, AutoIngestDat
List<String> command = new ArrayList<>(); List<String> command = new ArrayList<>();
for (final String l01Path : logicalEvidenceFilePaths) { for (final String l01Path : logicalEvidenceFilePaths) {
command.clear(); command.clear();
command.add(ewfexportPath.toAbsolutePath().toString()); command.add(String.format("\"%s\"", ewfexportPath.toAbsolutePath().toString()));
command.add("-f"); command.add("-f");
command.add("files"); command.add("files");
command.add("-t"); command.add("-t");
@ -203,8 +203,8 @@ public class LocalFilesDSProcessor implements DataSourceProcessor, AutoIngestDat
} }
Path dirPath = Paths.get(FilenameUtils.getBaseName(l01Path) + UNIQUENESS_CONSTRAINT_SEPERATOR + System.currentTimeMillis()); Path dirPath = Paths.get(FilenameUtils.getBaseName(l01Path) + UNIQUENESS_CONSTRAINT_SEPERATOR + System.currentTimeMillis());
command.add(dirPath.toString()); command.add(String.format("\"%s\"", dirPath.toString()));
command.add(l01Path); command.add(String.format("\"%s\"", l01Path));
ProcessBuilder processBuilder = new ProcessBuilder(command); ProcessBuilder processBuilder = new ProcessBuilder(command);
processBuilder.directory(l01Dir); processBuilder.directory(l01Dir);
try { try {

View File

@ -173,10 +173,10 @@ class UnpackagePortableCaseProgressDialog extends javax.swing.JDialog implements
throw new TskCoreException("Error finding 7-Zip executable"); // NON-NLS throw new TskCoreException("Error finding 7-Zip executable"); // NON-NLS
} }
String outputFolderSwitch = "-o" + outputFolder; // NON-NLS String outputFolderSwitch = "-o" + String.format("\"%s\"",outputFolder); // NON-NLS
ProcessBuilder procBuilder = new ProcessBuilder(); ProcessBuilder procBuilder = new ProcessBuilder();
procBuilder.command( procBuilder.command(
sevenZipExe.getAbsolutePath(), String.format("\"%s\"",sevenZipExe.getAbsolutePath()),
"x", // Extract "x", // Extract
packagedCase, packagedCase,
outputFolderSwitch outputFolderSwitch

View File

@ -210,8 +210,8 @@ public class ILeappAnalyzerIngestModule implements DataSourceIngestModule {
ProcessBuilder processBuilder = buildProcessWithRunAsInvoker( ProcessBuilder processBuilder = buildProcessWithRunAsInvoker(
"\"" + iLeappExecutable + "\"", //NON-NLS "\"" + iLeappExecutable + "\"", //NON-NLS
"-t", iLeappFileSystemType, //NON-NLS "-t", iLeappFileSystemType, //NON-NLS
"-i", sourceFilePath, //NON-NLS "-i", String.format("\"%s\"",sourceFilePath), //NON-NLS
"-o", moduleOutputPath.toString() "-o", String.format("\"%s\"",moduleOutputPath.toString())
); );
processBuilder.redirectError(moduleOutputPath.resolve("iLeapp_err.txt").toFile()); //NON-NLS processBuilder.redirectError(moduleOutputPath.resolve("iLeapp_err.txt").toFile()); //NON-NLS
processBuilder.redirectOutput(moduleOutputPath.resolve("iLeapp_out.txt").toFile()); //NON-NLS processBuilder.redirectOutput(moduleOutputPath.resolve("iLeapp_out.txt").toFile()); //NON-NLS

View File

@ -321,9 +321,9 @@ final class PhotoRecCarverFileIngestModule implements FileIngestModule {
ProcessBuilder processAndSettings = new ProcessBuilder( ProcessBuilder processAndSettings = new ProcessBuilder(
executableFile.toString(), executableFile.toString(),
"/d", // NON-NLS "/d", // NON-NLS
outputDirPath.toAbsolutePath().toString() + File.separator + PHOTOREC_RESULTS_BASE, String.format("\"%s\"", Paths.get(outputDirPath.toAbsolutePath().toString(), PHOTOREC_RESULTS_BASE).toString()),
"/cmd", // NON-NLS "/cmd", // NON-NLS
tempFilePath.toFile().toString()); String.format("\"%s\"",tempFilePath.toFile().toString()));
processAndSettings.command().add(this.optionsString); processAndSettings.command().add(this.optionsString);

View File

@ -48,6 +48,7 @@ import org.sleuthkit.autopsy.coreutils.ExecUtil;
import org.sleuthkit.autopsy.coreutils.FileUtil; import org.sleuthkit.autopsy.coreutils.FileUtil;
import org.sleuthkit.autopsy.coreutils.Logger; import org.sleuthkit.autopsy.coreutils.Logger;
import org.sleuthkit.autopsy.coreutils.PlatformUtil; import org.sleuthkit.autopsy.coreutils.PlatformUtil;
import org.sleuthkit.autopsy.ingest.FileIngestModuleProcessTerminator;
import org.sleuthkit.autopsy.ingest.IngestJobContext; import org.sleuthkit.autopsy.ingest.IngestJobContext;
import org.sleuthkit.autopsy.ingest.IngestServices; import org.sleuthkit.autopsy.ingest.IngestServices;
import org.sleuthkit.autopsy.ingest.ModuleContentEvent; import org.sleuthkit.autopsy.ingest.ModuleContentEvent;
@ -71,7 +72,7 @@ public class HEICProcessor implements PictureProcessor {
private static final int EXIT_SUCCESS = 0; private static final int EXIT_SUCCESS = 0;
private static final String HEIC_MODULE_FOLDER = "HEIC"; private static final String HEIC_MODULE_FOLDER = "HEIC";
private static final long TIMEOUT_IN_MS = TimeUnit.MILLISECONDS.convert(2, TimeUnit.MINUTES); private static final long TIMEOUT_IN_SEC = TimeUnit.SECONDS.convert(2, TimeUnit.MINUTES);
// Windows location // Windows location
private static final String IMAGE_MAGICK_FOLDER = "ImageMagick-7.0.10-27-portable-Q16-x64"; private static final String IMAGE_MAGICK_FOLDER = "ImageMagick-7.0.10-27-portable-Q16-x64";
@ -188,16 +189,13 @@ public class HEICProcessor implements PictureProcessor {
// Any additional images found within the HEIC container will be // Any additional images found within the HEIC container will be
// formatted as fileName-1.jpg, fileName-2.jpg, etc. // formatted as fileName-1.jpg, fileName-2.jpg, etc.
final ProcessBuilder processBuilder = new ProcessBuilder() final ProcessBuilder processBuilder = new ProcessBuilder()
.command(IMAGE_MAGICK_PATH.toString(), .command(String.format("\"%s\"",IMAGE_MAGICK_PATH.toString()),
localDiskCopy.toString(), String.format("\"%s\"",localDiskCopy.toString()),
outputFile.toString()); String.format("\"%s\"",outputFile.toString()));
processBuilder.redirectError(imageMagickErrorOutput.toFile()); processBuilder.redirectError(imageMagickErrorOutput.toFile());
final long startTime = System.currentTimeMillis(); final int exitStatus = ExecUtil.execute(processBuilder, new FileIngestModuleProcessTerminator(context, TIMEOUT_IN_SEC));
final int exitStatus = ExecUtil.execute(processBuilder, () -> {
return context.fileIngestIsCancelled() || System.currentTimeMillis() - startTime >= TIMEOUT_IN_MS;
});
if (context.fileIngestIsCancelled()) { if (context.fileIngestIsCancelled()) {
return; return;

View File

@ -235,8 +235,8 @@ public class PlasoIngestModule implements DataSourceIngestModule {
"--parsers", "\"" + parsersString + "\"",//NON-NLS "--parsers", "\"" + parsersString + "\"",//NON-NLS
"--no_dependencies_check", //NON-NLS "--no_dependencies_check", //NON-NLS
"--workers", String.valueOf(LOG2TIMELINE_WORKERS),//NON-NLS "--workers", String.valueOf(LOG2TIMELINE_WORKERS),//NON-NLS
moduleOutputPath.resolve(PLASO).toString(), String.format("\"%s\"",moduleOutputPath.resolve(PLASO).toString()),
image.getPaths()[0] String.format("\"%s\"",image.getPaths()[0])
); );
processBuilder.redirectError(moduleOutputPath.resolve("log2timeline_err.txt").toFile()); //NON-NLS processBuilder.redirectError(moduleOutputPath.resolve("log2timeline_err.txt").toFile()); //NON-NLS
return processBuilder; return processBuilder;
@ -256,8 +256,8 @@ public class PlasoIngestModule implements DataSourceIngestModule {
ProcessBuilder processBuilder = buildProcessWithRunAsInvoker( ProcessBuilder processBuilder = buildProcessWithRunAsInvoker(
"\"" + psortExecutable + "\"", //NON-NLS "\"" + psortExecutable + "\"", //NON-NLS
"-o", "4n6time_sqlite", //NON-NLS "-o", "4n6time_sqlite", //NON-NLS
"-w", moduleOutputPath.resolve("plasodb.db3").toString(), //NON-NLS "-w", String.format("\"%s\"",moduleOutputPath.resolve("plasodb.db3").toString()), //NON-NLS
moduleOutputPath.resolve(PLASO).toString() String.format("\"%s\"",moduleOutputPath.resolve(PLASO).toString())
); );
processBuilder.redirectOutput(moduleOutputPath.resolve("psort_output.txt").toFile()); //NON-NLS processBuilder.redirectOutput(moduleOutputPath.resolve("psort_output.txt").toFile()); //NON-NLS

View File

@ -1329,10 +1329,10 @@ public class PortableCaseReportModule implements ReportModule {
File zipFile = Paths.get(tempZipFolder.getAbsolutePath(), caseName + ".zip").toFile(); // NON-NLS File zipFile = Paths.get(tempZipFolder.getAbsolutePath(), caseName + ".zip").toFile(); // NON-NLS
ProcessBuilder procBuilder = new ProcessBuilder(); ProcessBuilder procBuilder = new ProcessBuilder();
procBuilder.command( procBuilder.command(
sevenZipExe.getAbsolutePath(), String.format("\"%s\"",sevenZipExe.getAbsolutePath()),
"a", // Add to archive "a", // Add to archive
zipFile.getAbsolutePath(), String.format("\"%s\"",zipFile.getAbsolutePath()),
dirToCompress.toAbsolutePath().toString(), String.format("\"%s\"",dirToCompress.toAbsolutePath().toString()),
chunkOption chunkOption
); );

View File

@ -196,7 +196,7 @@ class VolatilityProcessor {
List<String> commandLine = new ArrayList<>(); List<String> commandLine = new ArrayList<>();
commandLine.add("\"" + executableFile + "\""); //NON-NLS commandLine.add("\"" + executableFile + "\""); //NON-NLS
File memoryImage = new File(memoryImagePath); File memoryImage = new File(memoryImagePath);
commandLine.add("--filename=" + memoryImage.getName()); //NON-NLS commandLine.add("--filename=" + String.format("\"%s\"",memoryImage.getName())); //NON-NLS
if (!profile.isEmpty()) { if (!profile.isEmpty()) {
commandLine.add("--profile=" + profile); //NON-NLS commandLine.add("--profile=" + profile); //NON-NLS
} }
@ -213,7 +213,7 @@ class VolatilityProcessor {
if (!directory.exists()) { if (!directory.exists()) {
directory.mkdirs(); directory.mkdirs();
} }
commandLine.add("--dump-dir=" + outputDir); //NON-NLS commandLine.add("--dump-dir=" + String.format("\"%s\"",outputDir)); //NON-NLS
break; break;
default: default:
break; break;

View File

@ -575,10 +575,10 @@ final class ExtractEdge extends Extract {
List<String> commandLine = new ArrayList<>(); List<String> commandLine = new ArrayList<>();
commandLine.add(dumperPath); commandLine.add(dumperPath);
commandLine.add("/table"); //NON-NLS commandLine.add("/table"); //NON-NLS
commandLine.add(inputFilePath); commandLine.add(String.format("\"%s\"",inputFilePath));
commandLine.add("*"); //NON-NLS commandLine.add("*"); //NON-NLS
commandLine.add("/scomma"); //NON-NLS commandLine.add("/scomma"); //NON-NLS
commandLine.add(outputDir + "\\" + "*.csv"); //NON-NLS commandLine.add(String.format("\"%s\"",outputDir + "\\" + "*.csv")); //NON-NLS
ProcessBuilder processBuilder = new ProcessBuilder(commandLine); ProcessBuilder processBuilder = new ProcessBuilder(commandLine);
processBuilder.redirectOutput(outputFilePath.toFile()); processBuilder.redirectOutput(outputFilePath.toFile());

View File

@ -400,7 +400,7 @@ class ExtractIE extends Extract {
List<String> commandLine = new ArrayList<>(); List<String> commandLine = new ArrayList<>();
commandLine.add(JAVA_PATH); commandLine.add(JAVA_PATH);
commandLine.add("-cp"); //NON-NLS commandLine.add("-cp"); //NON-NLS
commandLine.add(PASCO_LIB_PATH); commandLine.add(String.format("\"%s\"",PASCO_LIB_PATH));
commandLine.add("isi.pasco2.Main"); //NON-NLS commandLine.add("isi.pasco2.Main"); //NON-NLS
commandLine.add("-T"); //NON-NLS commandLine.add("-T"); //NON-NLS
commandLine.add("history"); //NON-NLS commandLine.add("history"); //NON-NLS

View File

@ -177,9 +177,9 @@ final class ExtractPrefetch extends Extract {
final Path errFilePath = Paths.get(tempOutPath, PREFETCH_ERROR_FILE_NAME); final Path errFilePath = Paths.get(tempOutPath, PREFETCH_ERROR_FILE_NAME);
List<String> commandLine = new ArrayList<>(); List<String> commandLine = new ArrayList<>();
commandLine.add(prefetchExePath); commandLine.add(String.format("\"%s\"",prefetchExePath));
commandLine.add(prefetchDir); //NON-NLS commandLine.add(String.format("\"%s\"",prefetchDir)); //NON-NLS
commandLine.add(tempOutFile); commandLine.add(String.format("\"%s\"",tempOutFile));
ProcessBuilder processBuilder = new ProcessBuilder(commandLine); ProcessBuilder processBuilder = new ProcessBuilder(commandLine);
processBuilder.redirectOutput(outputFilePath.toFile()); processBuilder.redirectOutput(outputFilePath.toFile());

View File

@ -472,7 +472,7 @@ class ExtractRegistry extends Extract {
commandLine.add(cmd); commandLine.add(cmd);
} }
commandLine.add("-r"); //NON-NLS commandLine.add("-r"); //NON-NLS
commandLine.add(hiveFilePath); commandLine.add(String.format("\"%s\"",hiveFilePath));
commandLine.add("-f"); //NON-NLS commandLine.add("-f"); //NON-NLS
commandLine.add(hiveFileType); commandLine.add(hiveFileType);

View File

@ -247,10 +247,10 @@ final class ExtractSru extends Extract {
final Path errFilePath = Paths.get(tempOutPath, SRU_ERROR_FILE_NAME); final Path errFilePath = Paths.get(tempOutPath, SRU_ERROR_FILE_NAME);
List<String> commandLine = new ArrayList<>(); List<String> commandLine = new ArrayList<>();
commandLine.add(sruExePath); commandLine.add(String.format("\"%s\"",sruExePath));
commandLine.add(sruFile); //NON-NLS commandLine.add(sruFile); //NON-NLS
commandLine.add(softwareHiveFile); commandLine.add(softwareHiveFile);
commandLine.add(tempOutFile); commandLine.add(String.format("\"%s\"",tempOutFile));
ProcessBuilder processBuilder = new ProcessBuilder(commandLine); ProcessBuilder processBuilder = new ProcessBuilder(commandLine);
processBuilder.redirectOutput(outputFilePath.toFile()); processBuilder.redirectOutput(outputFilePath.toFile());