mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-19 11:07:43 +00:00
Added multi user support to command line ingest.
This commit is contained in:
parent
e6e83682fe
commit
ea764e50f2
@ -42,6 +42,7 @@ class CommandLineCommand {
|
|||||||
*/
|
*/
|
||||||
static enum InputType {
|
static enum InputType {
|
||||||
CASE_NAME,
|
CASE_NAME,
|
||||||
|
CASE_TYPE,
|
||||||
CASES_BASE_DIR_PATH,
|
CASES_BASE_DIR_PATH,
|
||||||
CASE_FOLDER_PATH,
|
CASE_FOLDER_PATH,
|
||||||
DATA_SOURCE_PATH,
|
DATA_SOURCE_PATH,
|
||||||
|
@ -38,6 +38,7 @@ import org.netbeans.spi.sendopts.OptionProcessor;
|
|||||||
import org.openide.LifecycleManager;
|
import org.openide.LifecycleManager;
|
||||||
import org.openide.util.Lookup;
|
import org.openide.util.Lookup;
|
||||||
import org.sleuthkit.autopsy.casemodule.Case;
|
import org.sleuthkit.autopsy.casemodule.Case;
|
||||||
|
import org.sleuthkit.autopsy.casemodule.Case.CaseType;
|
||||||
import org.sleuthkit.autopsy.casemodule.CaseActionException;
|
import org.sleuthkit.autopsy.casemodule.CaseActionException;
|
||||||
import org.sleuthkit.autopsy.casemodule.CaseDetails;
|
import org.sleuthkit.autopsy.casemodule.CaseDetails;
|
||||||
import org.sleuthkit.autopsy.casemodule.CaseMetadata;
|
import org.sleuthkit.autopsy.casemodule.CaseMetadata;
|
||||||
@ -157,7 +158,12 @@ public class CommandLineIngestManager {
|
|||||||
Map<String, String> inputs = command.getInputs();
|
Map<String, String> inputs = command.getInputs();
|
||||||
String baseCaseName = inputs.get(CommandLineCommand.InputType.CASE_NAME.name());
|
String baseCaseName = inputs.get(CommandLineCommand.InputType.CASE_NAME.name());
|
||||||
String rootOutputDirectory = inputs.get(CommandLineCommand.InputType.CASES_BASE_DIR_PATH.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);
|
String outputDirPath = getOutputDirPath(caseForJob);
|
||||||
OutputGenerator.saveCreateCaseOutput(caseForJob, outputDirPath, baseCaseName);
|
OutputGenerator.saveCreateCaseOutput(caseForJob, outputDirPath, baseCaseName);
|
||||||
@ -340,7 +346,7 @@ public class CommandLineIngestManager {
|
|||||||
*
|
*
|
||||||
* @throws CaseActionException
|
* @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});
|
LOGGER.log(Level.INFO, "Opening case {0} in directory {1}", new Object[]{baseCaseName, rootOutputDirectory});
|
||||||
Path caseDirectoryPath = findCaseDirectory(Paths.get(rootOutputDirectory), baseCaseName);
|
Path caseDirectoryPath = findCaseDirectory(Paths.get(rootOutputDirectory), baseCaseName);
|
||||||
@ -355,7 +361,7 @@ public class CommandLineIngestManager {
|
|||||||
Case.createCaseDirectory(caseDirectoryPath.toString(), Case.CaseType.SINGLE_USER_CASE);
|
Case.createCaseDirectory(caseDirectoryPath.toString(), Case.CaseType.SINGLE_USER_CASE);
|
||||||
|
|
||||||
CaseDetails caseDetails = new CaseDetails(baseCaseName);
|
CaseDetails caseDetails = new CaseDetails(baseCaseName);
|
||||||
Case.createAsCurrentCase(Case.CaseType.SINGLE_USER_CASE, caseDirectoryPath.toString(), caseDetails);
|
Case.createAsCurrentCase(caseType, caseDirectoryPath.toString(), caseDetails);
|
||||||
}
|
}
|
||||||
|
|
||||||
caseForJob = Case.getCurrentCase();
|
caseForJob = Case.getCurrentCase();
|
||||||
|
@ -31,6 +31,7 @@ import org.netbeans.spi.sendopts.Env;
|
|||||||
import org.netbeans.spi.sendopts.Option;
|
import org.netbeans.spi.sendopts.Option;
|
||||||
import org.netbeans.spi.sendopts.OptionProcessor;
|
import org.netbeans.spi.sendopts.OptionProcessor;
|
||||||
import org.openide.util.lookup.ServiceProvider;
|
import org.openide.util.lookup.ServiceProvider;
|
||||||
|
import org.sleuthkit.autopsy.featureaccess.FeatureAccessUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class can be used to add command line options to Autopsy
|
* 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 static final Logger logger = Logger.getLogger(CommandLineOptionProcessor.class.getName());
|
||||||
private final Option caseNameOption = Option.requiredArgument('n', "caseName");
|
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 caseBaseDirOption = Option.requiredArgument('o', "caseBaseDir");
|
||||||
private final Option createCaseCommandOption = Option.withoutArgument('c', "createCase");
|
private final Option createCaseCommandOption = Option.withoutArgument('c', "createCase");
|
||||||
private final Option dataSourcePathOption = Option.requiredArgument('s', "dataSourcePath");
|
private final Option dataSourcePathOption = Option.requiredArgument('s', "dataSourcePath");
|
||||||
@ -55,11 +57,15 @@ public class CommandLineOptionProcessor extends OptionProcessor {
|
|||||||
|
|
||||||
private final List<CommandLineCommand> commands = new ArrayList<>();
|
private final List<CommandLineCommand> commands = new ArrayList<>();
|
||||||
|
|
||||||
|
final static String CASETYPE_MULTI = "multi";
|
||||||
|
final static String CASETYPE_SINGLE = "single";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Set<Option> getOptions() {
|
protected Set<Option> getOptions() {
|
||||||
Set<Option> set = new HashSet<>();
|
Set<Option> set = new HashSet<>();
|
||||||
set.add(createCaseCommandOption);
|
set.add(createCaseCommandOption);
|
||||||
set.add(caseNameOption);
|
set.add(caseNameOption);
|
||||||
|
set.add(caseTypeOption);
|
||||||
set.add(caseBaseDirOption);
|
set.add(caseBaseDirOption);
|
||||||
set.add(dataSourcePathOption);
|
set.add(dataSourcePathOption);
|
||||||
set.add(addDataSourceCommandOption);
|
set.add(addDataSourceCommandOption);
|
||||||
@ -107,6 +113,37 @@ public class CommandLineOptionProcessor extends OptionProcessor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
String caseType = "";
|
||||||
|
if (values.containsKey(caseTypeOption)) {
|
||||||
|
argDirs = values.get(caseTypeOption);
|
||||||
|
|
||||||
|
if (argDirs.length < 1) {
|
||||||
|
logger.log(Level.SEVERE, "Missing argument 'caseType'");
|
||||||
|
System.err.println("Missing argument 'caseType'");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
caseType = argDirs[0];
|
||||||
|
|
||||||
|
if (caseType == null || caseType.isEmpty()) {
|
||||||
|
logger.log(Level.SEVERE, "'caseType' argument is empty");
|
||||||
|
System.err.println("'caseType' argument is empty");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!caseType.equalsIgnoreCase(CASETYPE_MULTI) && !caseType.equalsIgnoreCase(CASETYPE_SINGLE)) {
|
||||||
|
logger.log(Level.SEVERE, "'caseType' argument is invalid");
|
||||||
|
System.err.println("'caseType' argument is invalid");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (caseType.equalsIgnoreCase(CASETYPE_MULTI) && !FeatureAccessUtils.canCreateMultiUserCases()) {
|
||||||
|
logger.log(Level.SEVERE, "Unable to create multi user case.");
|
||||||
|
System.err.println("Unable to create multi user case. Confirm that multi user settings are configured correctly.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
String caseBaseDir = "";
|
String caseBaseDir = "";
|
||||||
if (values.containsKey(caseBaseDirOption)) {
|
if (values.containsKey(caseBaseDirOption)) {
|
||||||
argDirs = values.get(caseBaseDirOption);
|
argDirs = values.get(caseBaseDirOption);
|
||||||
@ -241,6 +278,7 @@ public class CommandLineOptionProcessor extends OptionProcessor {
|
|||||||
CommandLineCommand newCommand = new CommandLineCommand(CommandLineCommand.CommandType.CREATE_CASE);
|
CommandLineCommand newCommand = new CommandLineCommand(CommandLineCommand.CommandType.CREATE_CASE);
|
||||||
newCommand.addInputValue(CommandLineCommand.InputType.CASE_NAME.name(), inputCaseName);
|
newCommand.addInputValue(CommandLineCommand.InputType.CASE_NAME.name(), inputCaseName);
|
||||||
newCommand.addInputValue(CommandLineCommand.InputType.CASES_BASE_DIR_PATH.name(), caseBaseDir);
|
newCommand.addInputValue(CommandLineCommand.InputType.CASES_BASE_DIR_PATH.name(), caseBaseDir);
|
||||||
|
newCommand.addInputValue(CommandLineCommand.InputType.CASE_TYPE.name(), caseType);
|
||||||
commands.add(newCommand);
|
commands.add(newCommand);
|
||||||
runFromCommandLine = true;
|
runFromCommandLine = true;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user