From db8a613d28386f96d6e708deb0a4d6aefcfb6969 Mon Sep 17 00:00:00 2001 From: Greg DiCristofaro Date: Thu, 16 Jan 2025 12:34:11 -0500 Subject: [PATCH] updates for cli ingest --- .../CommandLineOptionProcessor.java | 2 +- .../autopsy/coreutils/DataSourceUtils.java | 27 ++++++++++++++----- .../DataSourceProcessorUtility.java | 2 +- 3 files changed, 23 insertions(+), 8 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/commandlineingest/CommandLineOptionProcessor.java b/Core/src/org/sleuthkit/autopsy/commandlineingest/CommandLineOptionProcessor.java index 1d4b55f49a..dc2a84e727 100755 --- a/Core/src/org/sleuthkit/autopsy/commandlineingest/CommandLineOptionProcessor.java +++ b/Core/src/org/sleuthkit/autopsy/commandlineingest/CommandLineOptionProcessor.java @@ -53,7 +53,7 @@ public class CommandLineOptionProcessor extends OptionProcessor { private final Option dataSourcePathOption = Option.requiredArgument('s', "dataSourcePath"); private final Option dataSourceObjectIdOption = Option.requiredArgument('i', "dataSourceObjectId"); private final Option addDataSourceCommandOption = Option.withoutArgument('a', "addDataSource"); - private final Option bitlockerKeyCommandOption = Option.withoutArgument('k', "key"); + private final Option bitlockerKeyCommandOption = Option.requiredArgument('k', "key"); private final Option runIngestCommandOption = Option.optionalArgument('r', "runIngest"); private final Option listAllDataSourcesCommandOption = Option.withoutArgument('l', "listAllDataSources"); private final Option generateReportsOption = Option.optionalArgument('g', "generateReports"); diff --git a/Core/src/org/sleuthkit/autopsy/coreutils/DataSourceUtils.java b/Core/src/org/sleuthkit/autopsy/coreutils/DataSourceUtils.java index 707c6b6645..5fe577a896 100644 --- a/Core/src/org/sleuthkit/autopsy/coreutils/DataSourceUtils.java +++ b/Core/src/org/sleuthkit/autopsy/coreutils/DataSourceUtils.java @@ -22,13 +22,15 @@ import org.sleuthkit.datamodel.SleuthkitJNI; import java.io.IOException; import java.nio.file.Path; import java.text.MessageFormat; +import java.util.logging.Level; import org.apache.commons.lang3.StringUtils; /** * Utility methods for working with data sources. */ public class DataSourceUtils { - + private static final Logger logger = Logger.getLogger(DataSourceUtils.class.getName()); + /** * Calls TSK to determine whether a * potential data source has a file system. @@ -44,24 +46,37 @@ public class DataSourceUtils { return SleuthkitJNI.isImageSupported(dataSourcePath.toString()); } + /** + * Calls TSK to determine whether a + * potential data source has a file system. + * + * @param dataSourcePath The path to the data source. + * @param password The password to decrypt the image. + * + * @return True or false. + * + * @throws IOException if an error occurs while trying to determine if the + * data source has a file system. + */ public static boolean imageHasFileSystem(Path dataSourcePath, String password) throws IOException { try { -// LOGGER.info("Testing if disk image {} can be opened", hostPath); SleuthkitJNI.TestOpenImageResult openImageResult = SleuthkitJNI.testOpenImage(dataSourcePath.toString(), password); - if (!openImageResult.wasSuccessful()) { + if (openImageResult.wasSuccessful()) { + return true; + } else { String message = MessageFormat.format("An error occurred while opening {0}: {1}", dataSourcePath.toString(), openImageResult == null || StringUtils.isBlank(openImageResult.getMessage()) ? "" : openImageResult.getMessage()); + logger.log(Level.INFO, message); return false; } } catch (Throwable ex) { String message = "An error occurred while opening " + dataSourcePath.toString(); + logger.log(Level.WARNING, message); return false; - } - return SleuthkitJNI.isImageSupported(dataSourcePath.toString()); - + } } } diff --git a/Core/src/org/sleuthkit/autopsy/datasourceprocessors/DataSourceProcessorUtility.java b/Core/src/org/sleuthkit/autopsy/datasourceprocessors/DataSourceProcessorUtility.java index 0d08545e7e..d96a0121a5 100644 --- a/Core/src/org/sleuthkit/autopsy/datasourceprocessors/DataSourceProcessorUtility.java +++ b/Core/src/org/sleuthkit/autopsy/datasourceprocessors/DataSourceProcessorUtility.java @@ -157,7 +157,7 @@ public class DataSourceProcessorUtility { * org.sleuthkit.autopsy.datasourceprocessors.AutoIngestDataSourceProcessor.AutoIngestDataSourceProcessorException */ public static List getOrderedListOfDataSourceProcessors(Path dataSourcePath, String password, Collection processorCandidates) throws AutoIngestDataSourceProcessorException { - Map validDataSourceProcessorsMap = getDataSourceProcessorForFile(dataSourcePath, processorCandidates); + Map validDataSourceProcessorsMap = getDataSourceProcessorForFile(dataSourcePath, password, processorCandidates); return orderDataSourceProcessorsByConfidence(validDataSourceProcessorsMap); }