From 8c50c9b23df5b6b878f391a9a31da8909570c409 Mon Sep 17 00:00:00 2001 From: Eugene Livis Date: Tue, 7 May 2019 11:29:30 -0400 Subject: [PATCH 001/192] First cut at storing commands and passing them around --- .../commandlineingest/CommandLineCommand.java | 48 +++++++++++++++ .../CommandLineIngestManager.java | 3 + .../CommandLineOptionProcessor.java | 60 +++++++++++++++---- 3 files changed, 98 insertions(+), 13 deletions(-) create mode 100755 Core/src/org/sleuthkit/autopsy/commandlineingest/CommandLineCommand.java diff --git a/Core/src/org/sleuthkit/autopsy/commandlineingest/CommandLineCommand.java b/Core/src/org/sleuthkit/autopsy/commandlineingest/CommandLineCommand.java new file mode 100755 index 0000000000..e72d444189 --- /dev/null +++ b/Core/src/org/sleuthkit/autopsy/commandlineingest/CommandLineCommand.java @@ -0,0 +1,48 @@ +/* + * Autopsy Forensic Browser + * + * Copyright 2019-2019 Basis Technology Corp. + * Contact: carrier sleuthkit org + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.sleuthkit.autopsy.commandlineingest; + +import java.util.HashMap; +import java.util.Map; + +/** + * Class that contains list of input parameters passed in via command line. + */ +class CommandLineCommand { + + /** + * An enumeration of command types. + */ + static enum CommandType { + CREATE_CASE, + ADD_DATA_SOURCE, + RUN_INGEST; + } + + CommandType type; + Map commands = new HashMap<>(); + + CommandLineCommand(CommandType type) { + this.type = type; + } + + void addInputValue(String inputName, String inputValue) { + commands.put(inputName, inputValue); + } +} diff --git a/Core/src/org/sleuthkit/autopsy/commandlineingest/CommandLineIngestManager.java b/Core/src/org/sleuthkit/autopsy/commandlineingest/CommandLineIngestManager.java index bbe14c0020..e788c929e2 100755 --- a/Core/src/org/sleuthkit/autopsy/commandlineingest/CommandLineIngestManager.java +++ b/Core/src/org/sleuthkit/autopsy/commandlineingest/CommandLineIngestManager.java @@ -108,6 +108,7 @@ public class CommandLineIngestManager { LOGGER.log(Level.INFO, "Autopsy is running from command line"); //NON-NLS String dataSourcePath = ""; String baseCaseName = ""; + List commands; // first look up all OptionProcessors and get input data from CommandLineOptionProcessor Collection optionProcessors = Lookup.getDefault().lookupAll(OptionProcessor.class); @@ -119,6 +120,8 @@ public class CommandLineIngestManager { // check if we are running from command line dataSourcePath = ((CommandLineOptionProcessor) processor).getPathToDataSource(); baseCaseName = ((CommandLineOptionProcessor) processor).getBaseCaseName(); + + commands = ((CommandLineOptionProcessor) processor).getCommands(); } } diff --git a/Core/src/org/sleuthkit/autopsy/commandlineingest/CommandLineOptionProcessor.java b/Core/src/org/sleuthkit/autopsy/commandlineingest/CommandLineOptionProcessor.java index 8b94961fa6..f7eb4e9492 100755 --- a/Core/src/org/sleuthkit/autopsy/commandlineingest/CommandLineOptionProcessor.java +++ b/Core/src/org/sleuthkit/autopsy/commandlineingest/CommandLineOptionProcessor.java @@ -19,7 +19,9 @@ package org.sleuthkit.autopsy.commandlineingest; import java.io.File; +import java.util.ArrayList; import java.util.HashSet; +import java.util.List; import java.util.Map; import java.util.Set; import java.util.logging.Level; @@ -37,18 +39,22 @@ import org.openide.util.lookup.ServiceProvider; public class CommandLineOptionProcessor extends OptionProcessor { private static final Logger logger = Logger.getLogger(CommandLineOptionProcessor.class.getName()); - private final Option pathToDataSourceOption = Option.optionalArgument('l', "inputPath"); - private final Option caseNameOption = Option.optionalArgument('2', "caseName"); + private final Option caseNameOption = Option.optionalArgument('1', "caseName"); + private final Option caseBaseDirOption = Option.optionalArgument('2', "caseBaseDir"); + private final Option dataSourcePathOption = Option.optionalArgument('4', "dataSourcePath"); private final Option runFromCommandLineOption = Option.optionalArgument('3', "runFromCommandLine"); private String pathToDataSource; private String baseCaseName; private boolean runFromCommandLine = false; + + private List commands = new ArrayList<>(); @Override protected Set