diff --git a/Core/src/org/sleuthkit/autopsy/commandlineingest/CommandLineCommand.java b/Core/src/org/sleuthkit/autopsy/commandlineingest/CommandLineCommand.java index f262244417..8888ac72de 100755 --- a/Core/src/org/sleuthkit/autopsy/commandlineingest/CommandLineCommand.java +++ b/Core/src/org/sleuthkit/autopsy/commandlineingest/CommandLineCommand.java @@ -33,7 +33,8 @@ class CommandLineCommand { CREATE_CASE, ADD_DATA_SOURCE, RUN_INGEST, - LIST_ALL_DATA_SOURCES; + LIST_ALL_DATA_SOURCES, + GENERATE_REPORTS; } /** diff --git a/Core/src/org/sleuthkit/autopsy/commandlineingest/CommandLineIngestManager.java b/Core/src/org/sleuthkit/autopsy/commandlineingest/CommandLineIngestManager.java index eb65945849..b64d4dda05 100755 --- a/Core/src/org/sleuthkit/autopsy/commandlineingest/CommandLineIngestManager.java +++ b/Core/src/org/sleuthkit/autopsy/commandlineingest/CommandLineIngestManager.java @@ -60,13 +60,15 @@ import org.sleuthkit.autopsy.ingest.IngestModuleError; import org.sleuthkit.autopsy.ingest.IngestProfiles; import org.sleuthkit.autopsy.modules.interestingitems.FilesSet; import org.sleuthkit.autopsy.modules.interestingitems.FilesSetsManager; +import org.sleuthkit.autopsy.report.ReportProgressLogger; +import org.sleuthkit.autopsy.report.ReportGenerator; import org.sleuthkit.datamodel.Content; import org.sleuthkit.datamodel.TskCoreException; /** * Allows Autopsy to be invoked with a command line arguments. Causes Autopsy to - * create a case, add a specified data source, run ingest on that data source, - * produce a CASE/UCO report and exit. + * create a case, add a specified data source, run ingest on that data source, + * list all data source in a case, generate reports. */ public class CommandLineIngestManager { @@ -265,6 +267,30 @@ public class CommandLineIngestManager { return; } break; + + case GENERATE_REPORTS: + try { + LOGGER.log(Level.INFO, "Processing 'Generate Reports' command"); + System.out.println("Processing 'Generate Reports' command"); + Map inputs = command.getInputs(); + + // open the case, if it hasn't been already opened by previous command + if (caseForJob == null) { + String caseDirPath = inputs.get(CommandLineCommand.InputType.CASE_FOLDER_PATH.name()); + openCase(caseDirPath); + } + + // generate reports + ReportGenerator generator = new ReportGenerator(CommandLineIngestSettingsPanel.REPORTING_CONFIGURATION_NAME, new ReportProgressLogger()); //NON-NLS + generator.generateReports(); + } catch (CaseActionException ex) { + String caseDirPath = command.getInputs().get(CommandLineCommand.InputType.CASE_FOLDER_PATH.name()); + LOGGER.log(Level.SEVERE, "Error opening case in case directory: " + caseDirPath, ex); + System.err.println("Error opening case in case directory: " + caseDirPath); + // Do not process any other commands + return; + } + break; default: break; } diff --git a/Core/src/org/sleuthkit/autopsy/commandlineingest/CommandLineIngestSettingsPanel.java b/Core/src/org/sleuthkit/autopsy/commandlineingest/CommandLineIngestSettingsPanel.java index 0a76cdae2f..4f0cf7dc75 100755 --- a/Core/src/org/sleuthkit/autopsy/commandlineingest/CommandLineIngestSettingsPanel.java +++ b/Core/src/org/sleuthkit/autopsy/commandlineingest/CommandLineIngestSettingsPanel.java @@ -38,7 +38,7 @@ public class CommandLineIngestSettingsPanel extends javax.swing.JPanel { private static final long serialVersionUID = 1L; private static final Logger logger = Logger.getLogger(CommandLineIngestSettingsPanel.class.getName()); - private static final String REPORTING_CONFIGURATION_NAME = "CommandLineIngest"; + static final String REPORTING_CONFIGURATION_NAME = "CommandLineIngest"; private static final boolean DISPLAY_CASE_SPECIFIC_DATA = false; // do not try to display case specific data as there is likely no case open private static final boolean RUN_REPORTS = false; // do not generate reports as part of running the report wizard diff --git a/Core/src/org/sleuthkit/autopsy/commandlineingest/CommandLineOptionProcessor.java b/Core/src/org/sleuthkit/autopsy/commandlineingest/CommandLineOptionProcessor.java index 49017406eb..981fceffcb 100755 --- a/Core/src/org/sleuthkit/autopsy/commandlineingest/CommandLineOptionProcessor.java +++ b/Core/src/org/sleuthkit/autopsy/commandlineingest/CommandLineOptionProcessor.java @@ -49,6 +49,7 @@ public class CommandLineOptionProcessor extends OptionProcessor { private final Option runIngestCommandOption = Option.withoutArgument('r', "runIngest"); private final Option ingestProfileOption = Option.requiredArgument('p', "ingestProfile"); private final Option listAllDataSourcesCommandOption = Option.withoutArgument('l', "listAllDataSources"); + private final Option generateReportsOption = Option.withoutArgument('g', "generateReports"); private boolean runFromCommandLine = false; @@ -67,6 +68,7 @@ public class CommandLineOptionProcessor extends OptionProcessor { set.add(runIngestCommandOption); set.add(ingestProfileOption); set.add(listAllDataSourcesCommandOption); + set.add(generateReportsOption); return set; } @@ -78,7 +80,8 @@ public class CommandLineOptionProcessor extends OptionProcessor { // input arguments must contain at least one command if (!(values.containsKey(createCaseCommandOption) || values.containsKey(addDataSourceCommandOption) - || values.containsKey(runIngestCommandOption) || values.containsKey(listAllDataSourcesCommandOption))) { + || values.containsKey(runIngestCommandOption) || values.containsKey(listAllDataSourcesCommandOption) + || values.containsKey(generateReportsOption))) { // not running from command line logger.log(Level.INFO, "No command line commands passed in as inputs. Not running from command line."); //NON-NLS System.err.println("No command line commands passed in as inputs. Not running from command line."); @@ -315,6 +318,24 @@ public class CommandLineOptionProcessor extends OptionProcessor { commands.add(newCommand); runFromCommandLine = true; } + + // Add "GENERATE_REPORTS" command, if present + if (values.containsKey(generateReportsOption)) { + + // 'caseDir' must only be specified if the case is not being created during the current run + if (!values.containsKey(createCaseCommandOption) && caseDir.isEmpty()) { + // new case is not being created during this run, so 'caseDir' should have been specified + logger.log(Level.SEVERE, "'caseDir' argument is empty"); + System.err.println("'caseDir' argument is empty"); + runFromCommandLine = false; + return; + } + + CommandLineCommand newCommand = new CommandLineCommand(CommandLineCommand.CommandType.GENERATE_REPORTS); + newCommand.addInputValue(CommandLineCommand.InputType.CASE_FOLDER_PATH.name(), caseDir); + commands.add(newCommand); + runFromCommandLine = true; + } } /**