From ea764e50f29e2356683ddcfaa37e5e40b42d4d65 Mon Sep 17 00:00:00 2001 From: esaunders Date: Tue, 11 Feb 2020 16:43:15 -0500 Subject: [PATCH] Added multi user support to command line ingest. --- .../commandlineingest/CommandLineCommand.java | 1 + .../CommandLineIngestManager.java | 12 ++++-- .../CommandLineOptionProcessor.java | 38 +++++++++++++++++++ 3 files changed, 48 insertions(+), 3 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/commandlineingest/CommandLineCommand.java b/Core/src/org/sleuthkit/autopsy/commandlineingest/CommandLineCommand.java index 8888ac72de..29d3a2e9c5 100755 --- a/Core/src/org/sleuthkit/autopsy/commandlineingest/CommandLineCommand.java +++ b/Core/src/org/sleuthkit/autopsy/commandlineingest/CommandLineCommand.java @@ -42,6 +42,7 @@ class CommandLineCommand { */ static enum InputType { CASE_NAME, + CASE_TYPE, CASES_BASE_DIR_PATH, CASE_FOLDER_PATH, DATA_SOURCE_PATH, diff --git a/Core/src/org/sleuthkit/autopsy/commandlineingest/CommandLineIngestManager.java b/Core/src/org/sleuthkit/autopsy/commandlineingest/CommandLineIngestManager.java index 4d04e5dbbf..3dfaf53001 100755 --- a/Core/src/org/sleuthkit/autopsy/commandlineingest/CommandLineIngestManager.java +++ b/Core/src/org/sleuthkit/autopsy/commandlineingest/CommandLineIngestManager.java @@ -38,6 +38,7 @@ import org.netbeans.spi.sendopts.OptionProcessor; import org.openide.LifecycleManager; import org.openide.util.Lookup; import org.sleuthkit.autopsy.casemodule.Case; +import org.sleuthkit.autopsy.casemodule.Case.CaseType; import org.sleuthkit.autopsy.casemodule.CaseActionException; import org.sleuthkit.autopsy.casemodule.CaseDetails; import org.sleuthkit.autopsy.casemodule.CaseMetadata; @@ -157,7 +158,12 @@ public class CommandLineIngestManager { Map inputs = command.getInputs(); String baseCaseName = inputs.get(CommandLineCommand.InputType.CASE_NAME.name()); String rootOutputDirectory = inputs.get(CommandLineCommand.InputType.CASES_BASE_DIR_PATH.name()); - openCase(baseCaseName, rootOutputDirectory); + CaseType caseType = CaseType.SINGLE_USER_CASE; + String caseTypeString = inputs.get(CommandLineCommand.InputType.CASE_TYPE.name()); + if (caseTypeString != null && caseTypeString.equalsIgnoreCase(CommandLineOptionProcessor.CASETYPE_MULTI)) { + caseType = CaseType.MULTI_USER_CASE; + } + openCase(baseCaseName, rootOutputDirectory, caseType); String outputDirPath = getOutputDirPath(caseForJob); OutputGenerator.saveCreateCaseOutput(caseForJob, outputDirPath, baseCaseName); @@ -340,7 +346,7 @@ public class CommandLineIngestManager { * * @throws CaseActionException */ - private void openCase(String baseCaseName, String rootOutputDirectory) throws CaseActionException { + private void openCase(String baseCaseName, String rootOutputDirectory, CaseType caseType) throws CaseActionException { LOGGER.log(Level.INFO, "Opening case {0} in directory {1}", new Object[]{baseCaseName, rootOutputDirectory}); Path caseDirectoryPath = findCaseDirectory(Paths.get(rootOutputDirectory), baseCaseName); @@ -355,7 +361,7 @@ public class CommandLineIngestManager { Case.createCaseDirectory(caseDirectoryPath.toString(), Case.CaseType.SINGLE_USER_CASE); CaseDetails caseDetails = new CaseDetails(baseCaseName); - Case.createAsCurrentCase(Case.CaseType.SINGLE_USER_CASE, caseDirectoryPath.toString(), caseDetails); + Case.createAsCurrentCase(caseType, caseDirectoryPath.toString(), caseDetails); } caseForJob = Case.getCurrentCase(); diff --git a/Core/src/org/sleuthkit/autopsy/commandlineingest/CommandLineOptionProcessor.java b/Core/src/org/sleuthkit/autopsy/commandlineingest/CommandLineOptionProcessor.java index 387d92293e..f23bd5f483 100755 --- a/Core/src/org/sleuthkit/autopsy/commandlineingest/CommandLineOptionProcessor.java +++ b/Core/src/org/sleuthkit/autopsy/commandlineingest/CommandLineOptionProcessor.java @@ -31,6 +31,7 @@ import org.netbeans.spi.sendopts.Env; import org.netbeans.spi.sendopts.Option; import org.netbeans.spi.sendopts.OptionProcessor; import org.openide.util.lookup.ServiceProvider; +import org.sleuthkit.autopsy.featureaccess.FeatureAccessUtils; /** * This class can be used to add command line options to Autopsy @@ -40,6 +41,7 @@ public class CommandLineOptionProcessor extends OptionProcessor { private static final Logger logger = Logger.getLogger(CommandLineOptionProcessor.class.getName()); private final Option caseNameOption = Option.requiredArgument('n', "caseName"); + private final Option caseTypeOption = Option.requiredArgument('t', "caseType"); private final Option caseBaseDirOption = Option.requiredArgument('o', "caseBaseDir"); private final Option createCaseCommandOption = Option.withoutArgument('c', "createCase"); private final Option dataSourcePathOption = Option.requiredArgument('s', "dataSourcePath"); @@ -55,11 +57,15 @@ public class CommandLineOptionProcessor extends OptionProcessor { private final List commands = new ArrayList<>(); + final static String CASETYPE_MULTI = "multi"; + final static String CASETYPE_SINGLE = "single"; + @Override protected Set