From 67f37ae03561efc01d00db242a37d398cb4391fd Mon Sep 17 00:00:00 2001 From: Kelly Kelly Date: Thu, 13 Aug 2020 15:28:01 -0400 Subject: [PATCH 1/4] Added command line support for using report profiles --- .../commandlineingest/Bundle.properties | 13 +- .../Bundle.properties-MERGED | 18 +- .../commandlineingest/CommandLineCommand.java | 3 +- .../CommandLineIngestManager.java | 286 ++++++++++-------- .../CommandLineIngestSettingsPanel.form | 278 +++++++++++------ .../CommandLineIngestSettingsPanel.java | 236 ++++++++++++--- .../CommandLineOptionProcessor.java | 35 ++- .../commandlineingest/CommandLinePanel.form | 2 +- .../commandlineingest/CommandLinePanel.java | 2 +- .../infrastructure/ReportWizardAction.java | 16 + .../infrastructure/ReportingConfigLoader.java | 24 ++ 11 files changed, 619 insertions(+), 294 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/commandlineingest/Bundle.properties b/Core/src/org/sleuthkit/autopsy/commandlineingest/Bundle.properties index 9c4f680119..6842d84579 100755 --- a/Core/src/org/sleuthkit/autopsy/commandlineingest/Bundle.properties +++ b/Core/src/org/sleuthkit/autopsy/commandlineingest/Bundle.properties @@ -2,11 +2,16 @@ OpenIDE-Module-Name=CommandLineAutopsy OptionsCategory_Keywords_Command_Line_Ingest_Settings=Command Line Ingest Settings OptionsCategory_Keywords_General=Options OptionsCategory_Name_Command_Line_Ingest=Command Line Ingest -CommandLinePanel.jLabel1.text=Ingest is running from command line +CommandLinePanel.jLabel1.text=Running command line taks. CommandLineStartupWindow.title.text=Running in Command Line Mode -CommandLineIngestSettingsPanel.bnEditIngestSettings.text=Configure Ingest +CommandLineIngestSettingsPanel.bnEditIngestSettings.text=Configure CommandLineIngestSettingsPanel.bnEditReportSettings.actionCommand=Report Module Settings CommandLineIngestSettingsPanel.bnEditReportSettings.toolTipText=Report generation settings for the command line processing mode context. -CommandLineIngestSettingsPanel.bnEditReportSettings.text=Configure Reporting -CommandLineIngestSettingsPanel.jLabelDescription.text=You can create cases, add data sources, run ingest modules, and generate reports from the command line.
This options panel allows you to configure the settings to use when running ingest modules and generating reports.
See the user documentation for details. +CommandLineIngestSettingsPanel.bnEditReportSettings.text=Configure CommandLineIngestSettingsPanel.bnEditIngestSettings.toolTipText=Ingest job settings for the command line processing mode context. +CommandLineIngestSettingsPanel.ingestDescriptionTextPane.text=Configure the profiles to use from the command line. +CommandLineIngestSettingsPanel.reportDescriptionTextPane.text=Report profiles define which report module and configuration to use. +CommandLineIngestSettingsPanel.reportProfileLabel.text=Report Profile: +CommandLineIngestSettingsPanel.ingestProfileLabel.text=Ingest Profile: +CommandLineIngestSettingsPanel.bnEditReportSettings.AccessibleContext.accessibleName=Configure +CommandLineIngestSettingsPanel.jTextPane1.text=Ingest profiles define which ingest filters, modules and configuration to use. diff --git a/Core/src/org/sleuthkit/autopsy/commandlineingest/Bundle.properties-MERGED b/Core/src/org/sleuthkit/autopsy/commandlineingest/Bundle.properties-MERGED index 9c4f680119..c9cdd86225 100755 --- a/Core/src/org/sleuthkit/autopsy/commandlineingest/Bundle.properties-MERGED +++ b/Core/src/org/sleuthkit/autopsy/commandlineingest/Bundle.properties-MERGED @@ -1,12 +1,22 @@ +CommandLineIngestSettingPanel_empty_report_name_mgs=Report profile name was empty, no profile created. +CommandLineIngestSettingPanel_existing_report_name_mgs=Report profile name was already exists, no profile created. +CommandListIngestSettingsPanel_Default_Report_DisplayName=Default +CommandListIngestSettingsPanel_Make_Config=Make new profile... +CommandListIngestSettingsPanel_Report_Name_Msg=Please supply a report profile name: OpenIDE-Module-Name=CommandLineAutopsy OptionsCategory_Keywords_Command_Line_Ingest_Settings=Command Line Ingest Settings OptionsCategory_Keywords_General=Options OptionsCategory_Name_Command_Line_Ingest=Command Line Ingest -CommandLinePanel.jLabel1.text=Ingest is running from command line +CommandLinePanel.jLabel1.text=Running command line taks. CommandLineStartupWindow.title.text=Running in Command Line Mode -CommandLineIngestSettingsPanel.bnEditIngestSettings.text=Configure Ingest +CommandLineIngestSettingsPanel.bnEditIngestSettings.text=Configure CommandLineIngestSettingsPanel.bnEditReportSettings.actionCommand=Report Module Settings CommandLineIngestSettingsPanel.bnEditReportSettings.toolTipText=Report generation settings for the command line processing mode context. -CommandLineIngestSettingsPanel.bnEditReportSettings.text=Configure Reporting -CommandLineIngestSettingsPanel.jLabelDescription.text=You can create cases, add data sources, run ingest modules, and generate reports from the command line.
This options panel allows you to configure the settings to use when running ingest modules and generating reports.
See the user documentation for details. +CommandLineIngestSettingsPanel.bnEditReportSettings.text=Configure CommandLineIngestSettingsPanel.bnEditIngestSettings.toolTipText=Ingest job settings for the command line processing mode context. +CommandLineIngestSettingsPanel.ingestDescriptionTextPane.text=Configure the profiles to use from the command line. +CommandLineIngestSettingsPanel.reportDescriptionTextPane.text=Report profiles define which report module and configuration to use. +CommandLineIngestSettingsPanel.reportProfileLabel.text=Report Profile: +CommandLineIngestSettingsPanel.ingestProfileLabel.text=Ingest Profile: +CommandLineIngestSettingsPanel.bnEditReportSettings.AccessibleContext.accessibleName=Configure +CommandLineIngestSettingsPanel.jTextPane1.text=Ingest profiles define which ingest filters, modules and configuration to use. diff --git a/Core/src/org/sleuthkit/autopsy/commandlineingest/CommandLineCommand.java b/Core/src/org/sleuthkit/autopsy/commandlineingest/CommandLineCommand.java index 29d3a2e9c5..109afcbcb4 100755 --- a/Core/src/org/sleuthkit/autopsy/commandlineingest/CommandLineCommand.java +++ b/Core/src/org/sleuthkit/autopsy/commandlineingest/CommandLineCommand.java @@ -47,7 +47,8 @@ class CommandLineCommand { CASE_FOLDER_PATH, DATA_SOURCE_PATH, DATA_SOURCE_ID, - INGEST_PROFILE_NAME; + INGEST_PROFILE_NAME, + REPORT_PROFILE_NAME; } private final CommandType type; diff --git a/Core/src/org/sleuthkit/autopsy/commandlineingest/CommandLineIngestManager.java b/Core/src/org/sleuthkit/autopsy/commandlineingest/CommandLineIngestManager.java index f5d9a5c641..a24a7a2c78 100755 --- a/Core/src/org/sleuthkit/autopsy/commandlineingest/CommandLineIngestManager.java +++ b/Core/src/org/sleuthkit/autopsy/commandlineingest/CommandLineIngestManager.java @@ -153,156 +153,160 @@ public class CommandLineIngestManager { switch (type) { case CREATE_CASE: try { - LOGGER.log(Level.INFO, "Processing 'Create Case' command"); - System.out.println("Processing 'Create Case' command"); - Map inputs = command.getInputs(); - String baseCaseName = inputs.get(CommandLineCommand.InputType.CASE_NAME.name()); - String rootOutputDirectory = inputs.get(CommandLineCommand.InputType.CASES_BASE_DIR_PATH.name()); - 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); - } catch (CaseActionException ex) { - String baseCaseName = command.getInputs().get(CommandLineCommand.InputType.CASE_NAME.name()); - LOGGER.log(Level.SEVERE, "Error creating or opening case " + baseCaseName, ex); - System.err.println("Error creating or opening case " + baseCaseName); - // Do not process any other commands - return; + LOGGER.log(Level.INFO, "Processing 'Create Case' command"); + System.out.println("Processing 'Create Case' command"); + Map inputs = command.getInputs(); + String baseCaseName = inputs.get(CommandLineCommand.InputType.CASE_NAME.name()); + String rootOutputDirectory = inputs.get(CommandLineCommand.InputType.CASES_BASE_DIR_PATH.name()); + 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; } - break; + openCase(baseCaseName, rootOutputDirectory, caseType); + + String outputDirPath = getOutputDirPath(caseForJob); + OutputGenerator.saveCreateCaseOutput(caseForJob, outputDirPath, baseCaseName); + } catch (CaseActionException ex) { + String baseCaseName = command.getInputs().get(CommandLineCommand.InputType.CASE_NAME.name()); + LOGGER.log(Level.SEVERE, "Error creating or opening case " + baseCaseName, ex); + System.err.println("Error creating or opening case " + baseCaseName); + // Do not process any other commands + return; + } + break; case ADD_DATA_SOURCE: try { - LOGGER.log(Level.INFO, "Processing 'Add Data Source' command"); - System.out.println("Processing 'Add Data Source' command"); - Map inputs = command.getInputs(); + LOGGER.log(Level.INFO, "Processing 'Add Data Source' command"); + System.out.println("Processing 'Add Data Source' command"); + Map inputs = command.getInputs(); - // open the case, if it hasn't been already opened by CREATE_CASE command - if (caseForJob == null) { - String caseDirPath = inputs.get(CommandLineCommand.InputType.CASE_FOLDER_PATH.name()); - openCase(caseDirPath); - } - - String dataSourcePath = inputs.get(CommandLineCommand.InputType.DATA_SOURCE_PATH.name()); - dataSource = new AutoIngestDataSource("", Paths.get(dataSourcePath)); - runDataSourceProcessor(caseForJob, dataSource); - - String outputDirPath = getOutputDirPath(caseForJob); - OutputGenerator.saveAddDataSourceOutput(caseForJob, dataSource, outputDirPath); - } catch (InterruptedException | AutoIngestDataSourceProcessor.AutoIngestDataSourceProcessorException | CaseActionException ex) { - String dataSourcePath = command.getInputs().get(CommandLineCommand.InputType.DATA_SOURCE_PATH.name()); - LOGGER.log(Level.SEVERE, "Error adding data source " + dataSourcePath, ex); - System.err.println("Error adding data source " + dataSourcePath); - // Do not process any other commands - return; + // open the case, if it hasn't been already opened by CREATE_CASE command + if (caseForJob == null) { + String caseDirPath = inputs.get(CommandLineCommand.InputType.CASE_FOLDER_PATH.name()); + openCase(caseDirPath); } - break; + + String dataSourcePath = inputs.get(CommandLineCommand.InputType.DATA_SOURCE_PATH.name()); + dataSource = new AutoIngestDataSource("", Paths.get(dataSourcePath)); + runDataSourceProcessor(caseForJob, dataSource); + + String outputDirPath = getOutputDirPath(caseForJob); + OutputGenerator.saveAddDataSourceOutput(caseForJob, dataSource, outputDirPath); + } catch (InterruptedException | AutoIngestDataSourceProcessor.AutoIngestDataSourceProcessorException | CaseActionException ex) { + String dataSourcePath = command.getInputs().get(CommandLineCommand.InputType.DATA_SOURCE_PATH.name()); + LOGGER.log(Level.SEVERE, "Error adding data source " + dataSourcePath, ex); + System.err.println("Error adding data source " + dataSourcePath); + // Do not process any other commands + return; + } + break; case RUN_INGEST: try { - LOGGER.log(Level.INFO, "Processing 'Run Ingest' command"); - System.out.println("Processing 'Run Ingest' command"); - Map inputs = command.getInputs(); + LOGGER.log(Level.INFO, "Processing 'Run Ingest' command"); + System.out.println("Processing 'Run Ingest' command"); + Map inputs = command.getInputs(); - // open the case, if it hasn't been already opened by CREATE_CASE or ADD_DATA_SOURCE commands - if (caseForJob == null) { - String caseDirPath = inputs.get(CommandLineCommand.InputType.CASE_FOLDER_PATH.name()); - openCase(caseDirPath); - } - - // populate the AutoIngestDataSource structure, if that hasn't been done by ADD_DATA_SOURCE command - if (dataSource == null) { - - String dataSourceId = inputs.get(CommandLineCommand.InputType.DATA_SOURCE_ID.name()); - Long dataSourceObjId = Long.valueOf(dataSourceId); - - // get Content object for the data source - Content content = null; - try { - content = Case.getCurrentCaseThrows().getSleuthkitCase().getContentById(dataSourceObjId); - } catch (TskCoreException ex) { - LOGGER.log(Level.SEVERE, "Exception while trying to find data source with object ID " + dataSourceId, ex); - System.err.println("Exception while trying to find data source with object ID " + dataSourceId); - // Do not process any other commands - return; - } - - if (content == null) { - LOGGER.log(Level.SEVERE, "Unable to find data source with object ID {0}", dataSourceId); - System.out.println("Unable to find data source with object ID " + dataSourceId); - // Do not process any other commands - return; - } - - // populate the AutoIngestDataSource structure - dataSource = new AutoIngestDataSource("", Paths.get(content.getName())); - List contentList = Arrays.asList(new Content[]{content}); - List errorList = new ArrayList<>(); - dataSource.setDataSourceProcessorOutput(NO_ERRORS, errorList, contentList); - } - - // run ingest - String ingestProfile = inputs.get(CommandLineCommand.InputType.INGEST_PROFILE_NAME.name()); - analyze(dataSource, ingestProfile); - } catch (InterruptedException | CaseActionException ex) { - String dataSourcePath = command.getInputs().get(CommandLineCommand.InputType.DATA_SOURCE_PATH.name()); - LOGGER.log(Level.SEVERE, "Error running ingest on data source " + dataSourcePath, ex); - System.err.println("Error running ingest on data source " + dataSourcePath); - // Do not process any other commands - return; + // open the case, if it hasn't been already opened by CREATE_CASE or ADD_DATA_SOURCE commands + if (caseForJob == null) { + String caseDirPath = inputs.get(CommandLineCommand.InputType.CASE_FOLDER_PATH.name()); + openCase(caseDirPath); } - break; + + // populate the AutoIngestDataSource structure, if that hasn't been done by ADD_DATA_SOURCE command + if (dataSource == null) { + + String dataSourceId = inputs.get(CommandLineCommand.InputType.DATA_SOURCE_ID.name()); + Long dataSourceObjId = Long.valueOf(dataSourceId); + + // get Content object for the data source + Content content = null; + try { + content = Case.getCurrentCaseThrows().getSleuthkitCase().getContentById(dataSourceObjId); + } catch (TskCoreException ex) { + LOGGER.log(Level.SEVERE, "Exception while trying to find data source with object ID " + dataSourceId, ex); + System.err.println("Exception while trying to find data source with object ID " + dataSourceId); + // Do not process any other commands + return; + } + + if (content == null) { + LOGGER.log(Level.SEVERE, "Unable to find data source with object ID {0}", dataSourceId); + System.out.println("Unable to find data source with object ID " + dataSourceId); + // Do not process any other commands + return; + } + + // populate the AutoIngestDataSource structure + dataSource = new AutoIngestDataSource("", Paths.get(content.getName())); + List contentList = Arrays.asList(new Content[]{content}); + List errorList = new ArrayList<>(); + dataSource.setDataSourceProcessorOutput(NO_ERRORS, errorList, contentList); + } + + // run ingest + String ingestProfile = inputs.get(CommandLineCommand.InputType.INGEST_PROFILE_NAME.name()); + analyze(dataSource, ingestProfile); + } catch (InterruptedException | CaseActionException ex) { + String dataSourcePath = command.getInputs().get(CommandLineCommand.InputType.DATA_SOURCE_PATH.name()); + LOGGER.log(Level.SEVERE, "Error running ingest on data source " + dataSourcePath, ex); + System.err.println("Error running ingest on data source " + dataSourcePath); + // Do not process any other commands + return; + } + break; case LIST_ALL_DATA_SOURCES: try { - LOGGER.log(Level.INFO, "Processing 'List All Data Sources' command"); - System.out.println("Processing 'List All Data Sources' command"); - Map inputs = command.getInputs(); + LOGGER.log(Level.INFO, "Processing 'List All Data Sources' command"); + System.out.println("Processing 'List All Data Sources' 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); - } - - String outputDirPath = getOutputDirPath(caseForJob); - OutputGenerator.listAllDataSources(caseForJob, outputDirPath); - } 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; + // 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); } - break; + + String outputDirPath = getOutputDirPath(caseForJob); + OutputGenerator.listAllDataSources(caseForJob, outputDirPath); + } 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; case GENERATE_REPORTS: try { - LOGGER.log(Level.INFO, "Processing 'Generate Reports' command"); - System.out.println("Processing 'Generate Reports' command"); - Map inputs = command.getInputs(); + 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 - ReportProgressIndicator progressIndicator = new ReportProgressIndicator(new LoggingProgressIndicator()); - ReportGenerator generator = new ReportGenerator(CommandLineIngestSettingsPanel.getReportingConfigName(), progressIndicator); - 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; + // 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); } - break; + String reportName = inputs.get(CommandLineCommand.InputType.REPORT_PROFILE_NAME.name()); + if (reportName == null) { + reportName = CommandLineIngestSettingsPanel.getDefaultReportingConfigName(); + } + + // generate reports + ReportProgressIndicator progressIndicator = new ReportProgressIndicator(new LoggingProgressIndicator()); + ReportGenerator generator = new ReportGenerator(reportName, progressIndicator); + 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; } @@ -343,7 +347,7 @@ public class CommandLineIngestManager { * @param baseCaseName Case name * @param rootOutputDirectory Full path to directory in which case * output folder will be created - * @param caseType Type of case being created + * @param caseType Type of case being created * * @throws CaseActionException */ @@ -434,8 +438,22 @@ public class CommandLineIngestManager { * processing * error * - * @throws ead running the job processing task is interrupted while - * blocked, i.e., if auto ingest is shutting down. + * @throws ead running + * the + * job + * processing + * task + * is + * interrupted + * while + * blocked, + * i.e., + * if + * auto + * ingest + * is + * shutting + * down. */ private void runDataSourceProcessor(Case caseForJob, AutoIngestDataSource dataSource) throws InterruptedException, AutoIngestDataSourceProcessor.AutoIngestDataSourceProcessorException { diff --git a/Core/src/org/sleuthkit/autopsy/commandlineingest/CommandLineIngestSettingsPanel.form b/Core/src/org/sleuthkit/autopsy/commandlineingest/CommandLineIngestSettingsPanel.form index c20e802081..6125fbb6c1 100755 --- a/Core/src/org/sleuthkit/autopsy/commandlineingest/CommandLineIngestSettingsPanel.form +++ b/Core/src/org/sleuthkit/autopsy/commandlineingest/CommandLineIngestSettingsPanel.form @@ -16,113 +16,207 @@ + - - - - - - - - - - - - + - + - + - + + + + + + - + - + - - + + - - + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Core/src/org/sleuthkit/autopsy/commandlineingest/CommandLineIngestSettingsPanel.java b/Core/src/org/sleuthkit/autopsy/commandlineingest/CommandLineIngestSettingsPanel.java index 63bad0bd23..a0a4eb384d 100755 --- a/Core/src/org/sleuthkit/autopsy/commandlineingest/CommandLineIngestSettingsPanel.java +++ b/Core/src/org/sleuthkit/autopsy/commandlineingest/CommandLineIngestSettingsPanel.java @@ -21,12 +21,16 @@ package org.sleuthkit.autopsy.commandlineingest; import java.awt.BorderLayout; import java.awt.Cursor; import java.util.List; +import java.util.Set; +import javax.swing.DefaultComboBoxModel; import javax.swing.JOptionPane; +import org.openide.util.NbBundle.Messages; import org.sleuthkit.autopsy.ingest.IngestJobSettings; import org.sleuthkit.autopsy.ingest.IngestJobSettingsPanel; import org.openide.windows.WindowManager; import org.sleuthkit.autopsy.coreutils.Logger; import static org.sleuthkit.autopsy.report.infrastructure.ReportWizardAction.doReportWizard; +import org.sleuthkit.autopsy.report.infrastructure.ReportWizardAction; /** * Configuration panel for auto ingest settings. @@ -36,7 +40,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"; private static final boolean DISPLAY_CASE_SPECIFIC_DATA = false; // do not try to display case specific data private static final boolean RUN_REPORTS = false; // do not generate reports as part of running the report wizard @@ -48,12 +52,13 @@ public class CommandLineIngestSettingsPanel extends javax.swing.JPanel { */ public CommandLineIngestSettingsPanel(CommandLineIngestSettingsPanelController theController) { initComponents(); + setupReportList(); } - + /** * @return the REPORTING_CONFIGURATION_NAME */ - public static String getReportingConfigName() { + public static String getDefaultReportingConfigName() { return REPORTING_CONFIGURATION_NAME; } @@ -87,6 +92,58 @@ public class CommandLineIngestSettingsPanel extends javax.swing.JPanel { } } + @Messages({ + "CommandListIngestSettingsPanel_Default_Report_DisplayName=Default", + "CommandListIngestSettingsPanel_Make_Config=Make new profile..." + }) + /** + * Initializes the report profile list combo box. + */ + private void setupReportList() { + Set configNames = ReportWizardAction.getReportConfigNames(); + configNames.remove(REPORTING_CONFIGURATION_NAME); + + DefaultComboBoxModel model = new DefaultComboBoxModel<>(); + model.addElement(Bundle.CommandListIngestSettingsPanel_Default_Report_DisplayName()); + for (String name : configNames) { + model.addElement(name); + } + + model.addElement(Bundle.CommandListIngestSettingsPanel_Make_Config()); + + reportProfileCB.setModel(model); + reportProfileCB.setSelectedIndex(0); + } + + /** + * Checks to see if there is currently a profile define with the given name. + * + * @param name Profile name to check. + * + * @return True if there is a report with the given name. + */ + private boolean doesReportProfileNameExist(String name) { + Set configNames = ReportWizardAction.getReportConfigNames(); + return configNames.contains(name); + } + + /** + * Returns the currently selected report profile name from the cb. For backwards + * compatibility if Default is selected, the existing default + * profile name of CommandLineIngest will be returned. + * + * @return The selected profile name. + */ + private String getReportName() { + String reportName = (String) reportProfileCB.getSelectedItem(); + + if (reportName.equals(Bundle.CommandListIngestSettingsPanel_Default_Report_DisplayName())) { + reportName = REPORTING_CONFIGURATION_NAME; + } + + return reportName; + } + /** * This method is called from within the constructor to initialize the form. * WARNING: Do NOT modify this code. The content of this method is always @@ -95,20 +152,26 @@ public class CommandLineIngestSettingsPanel extends javax.swing.JPanel { @SuppressWarnings("unchecked") // //GEN-BEGIN:initComponents private void initComponents() { + java.awt.GridBagConstraints gridBagConstraints; - nodeScrollPane = new javax.swing.JScrollPane(); nodePanel = new javax.swing.JPanel(); bnEditIngestSettings = new javax.swing.JButton(); - jLabelDescription = new javax.swing.JLabel(); bnEditReportSettings = new javax.swing.JButton(); + javax.swing.JTextPane ingestDescriptionTextPane = new javax.swing.JTextPane(); + javax.swing.JLabel ingestProfileLabel = new javax.swing.JLabel(); + ingestProfileCB = new javax.swing.JComboBox<>(); + javax.swing.JTextPane reportDescriptionTextPane = new javax.swing.JTextPane(); + javax.swing.JLabel reportProfileLabel = new javax.swing.JLabel(); + reportProfileCB = new javax.swing.JComboBox<>(); + javax.swing.Box.Filler bottomFiller = new javax.swing.Box.Filler(new java.awt.Dimension(0, 0), new java.awt.Dimension(0, 0), new java.awt.Dimension(0, 0)); + jTextPane1 = new javax.swing.JTextPane(); setPreferredSize(new java.awt.Dimension(810, 422)); - - nodeScrollPane.setMinimumSize(new java.awt.Dimension(0, 0)); - nodeScrollPane.setPreferredSize(new java.awt.Dimension(803, 553)); + setLayout(new java.awt.BorderLayout()); nodePanel.setMinimumSize(new java.awt.Dimension(100, 100)); nodePanel.setPreferredSize(new java.awt.Dimension(801, 551)); + nodePanel.setLayout(new java.awt.GridBagLayout()); org.openide.awt.Mnemonics.setLocalizedText(bnEditIngestSettings, org.openide.util.NbBundle.getMessage(CommandLineIngestSettingsPanel.class, "CommandLineIngestSettingsPanel.bnEditIngestSettings.text")); // NOI18N bnEditIngestSettings.setToolTipText(org.openide.util.NbBundle.getMessage(CommandLineIngestSettingsPanel.class, "CommandLineIngestSettingsPanel.bnEditIngestSettings.toolTipText")); // NOI18N @@ -118,8 +181,12 @@ public class CommandLineIngestSettingsPanel extends javax.swing.JPanel { bnEditIngestSettingsActionPerformed(evt); } }); - - org.openide.awt.Mnemonics.setLocalizedText(jLabelDescription, org.openide.util.NbBundle.getMessage(CommandLineIngestSettingsPanel.class, "CommandLineIngestSettingsPanel.jLabelDescription.text")); // NOI18N + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridx = 2; + gridBagConstraints.gridy = 2; + gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; + gridBagConstraints.insets = new java.awt.Insets(0, 9, 0, 0); + nodePanel.add(bnEditIngestSettings, gridBagConstraints); org.openide.awt.Mnemonics.setLocalizedText(bnEditReportSettings, org.openide.util.NbBundle.getMessage(CommandLineIngestSettingsPanel.class, "CommandLineIngestSettingsPanel.bnEditReportSettings.text")); // NOI18N bnEditReportSettings.setToolTipText(org.openide.util.NbBundle.getMessage(CommandLineIngestSettingsPanel.class, "CommandLineIngestSettingsPanel.bnEditReportSettings.toolTipText")); // NOI18N @@ -129,48 +196,120 @@ public class CommandLineIngestSettingsPanel extends javax.swing.JPanel { bnEditReportSettingsActionPerformed(evt); } }); + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridx = 2; + gridBagConstraints.gridy = 4; + gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; + gridBagConstraints.insets = new java.awt.Insets(0, 9, 0, 0); + nodePanel.add(bnEditReportSettings, gridBagConstraints); + bnEditReportSettings.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(CommandLineIngestSettingsPanel.class, "CommandLineIngestSettingsPanel.bnEditReportSettings.AccessibleContext.accessibleName")); // NOI18N - javax.swing.GroupLayout nodePanelLayout = new javax.swing.GroupLayout(nodePanel); - nodePanel.setLayout(nodePanelLayout); - nodePanelLayout.setHorizontalGroup( - nodePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(nodePanelLayout.createSequentialGroup() - .addContainerGap() - .addGroup(nodePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(bnEditIngestSettings, javax.swing.GroupLayout.PREFERRED_SIZE, 155, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(jLabelDescription, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(bnEditReportSettings, javax.swing.GroupLayout.PREFERRED_SIZE, 155, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) - ); - nodePanelLayout.setVerticalGroup( - nodePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(nodePanelLayout.createSequentialGroup() - .addGap(27, 27, 27) - .addComponent(jLabelDescription, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) - .addComponent(bnEditIngestSettings) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(bnEditReportSettings) - .addContainerGap(381, Short.MAX_VALUE)) - ); + ingestDescriptionTextPane.setEditable(false); + ingestDescriptionTextPane.setBackground(javax.swing.UIManager.getDefaults().getColor("Label.background")); + ingestDescriptionTextPane.setText(org.openide.util.NbBundle.getMessage(CommandLineIngestSettingsPanel.class, "CommandLineIngestSettingsPanel.ingestDescriptionTextPane.text")); // NOI18N + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridx = 0; + gridBagConstraints.gridy = 0; + gridBagConstraints.gridwidth = 3; + gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; + gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; + gridBagConstraints.weightx = 1.0; + gridBagConstraints.insets = new java.awt.Insets(5, 5, 10, 5); + nodePanel.add(ingestDescriptionTextPane, gridBagConstraints); - nodeScrollPane.setViewportView(nodePanel); + org.openide.awt.Mnemonics.setLocalizedText(ingestProfileLabel, org.openide.util.NbBundle.getMessage(CommandLineIngestSettingsPanel.class, "CommandLineIngestSettingsPanel.ingestProfileLabel.text")); // NOI18N + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridx = 0; + gridBagConstraints.gridy = 2; + gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; + gridBagConstraints.insets = new java.awt.Insets(0, 25, 0, 0); + nodePanel.add(ingestProfileLabel, gridBagConstraints); - javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); - this.setLayout(layout); - layout.setHorizontalGroup( - layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(nodeScrollPane, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - ); - layout.setVerticalGroup( - layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(nodeScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 421, Short.MAX_VALUE) - ); + ingestProfileCB.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "Default" })); + ingestProfileCB.setEnabled(false); + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridx = 1; + gridBagConstraints.gridy = 2; + gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; + gridBagConstraints.insets = new java.awt.Insets(0, 5, 0, 0); + nodePanel.add(ingestProfileCB, gridBagConstraints); + + reportDescriptionTextPane.setEditable(false); + reportDescriptionTextPane.setBackground(javax.swing.UIManager.getDefaults().getColor("Label.background")); + reportDescriptionTextPane.setText(org.openide.util.NbBundle.getMessage(CommandLineIngestSettingsPanel.class, "CommandLineIngestSettingsPanel.reportDescriptionTextPane.text")); // NOI18N + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridx = 0; + gridBagConstraints.gridy = 3; + gridBagConstraints.gridwidth = 3; + gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; + gridBagConstraints.insets = new java.awt.Insets(15, 5, 5, 5); + nodePanel.add(reportDescriptionTextPane, gridBagConstraints); + + org.openide.awt.Mnemonics.setLocalizedText(reportProfileLabel, org.openide.util.NbBundle.getMessage(CommandLineIngestSettingsPanel.class, "CommandLineIngestSettingsPanel.reportProfileLabel.text")); // NOI18N + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridx = 0; + gridBagConstraints.gridy = 4; + gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; + gridBagConstraints.insets = new java.awt.Insets(0, 25, 0, 0); + nodePanel.add(reportProfileLabel, gridBagConstraints); + + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridx = 1; + gridBagConstraints.gridy = 4; + gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; + gridBagConstraints.insets = new java.awt.Insets(0, 5, 0, 0); + nodePanel.add(reportProfileCB, gridBagConstraints); + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridx = 0; + gridBagConstraints.gridy = 5; + gridBagConstraints.weighty = 1.0; + nodePanel.add(bottomFiller, gridBagConstraints); + + jTextPane1.setEditable(false); + jTextPane1.setBackground(javax.swing.UIManager.getDefaults().getColor("Label.background")); + jTextPane1.setText(org.openide.util.NbBundle.getMessage(CommandLineIngestSettingsPanel.class, "CommandLineIngestSettingsPanel.jTextPane1.text")); // NOI18N + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridx = 0; + gridBagConstraints.gridy = 1; + gridBagConstraints.gridwidth = 3; + gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; + gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; + gridBagConstraints.insets = new java.awt.Insets(10, 5, 5, 5); + nodePanel.add(jTextPane1, gridBagConstraints); + + add(nodePanel, java.awt.BorderLayout.CENTER); }// //GEN-END:initComponents - + @Messages({ + "CommandListIngestSettingsPanel_Report_Name_Msg=Please supply a report profile name:", + "CommandLineIngestSettingPanel_empty_report_name_mgs=Report profile name was empty, no profile created.", + "CommandLineIngestSettingPanel_existing_report_name_mgs=Report profile name was already exists, no profile created." + }) private void bnEditReportSettingsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bnEditReportSettingsActionPerformed + String reportName = getReportName(); + if (reportName.equals(Bundle.CommandListIngestSettingsPanel_Make_Config())) { + reportName = JOptionPane.showInputDialog(this, Bundle.CommandListIngestSettingsPanel_Report_Name_Msg()); + + // User hit cancel + if (reportName == null) { + return; + } else if (reportName.isEmpty()) { + JOptionPane.showMessageDialog(WindowManager.getDefault().getMainWindow(), Bundle.CommandLineIngestSettingPanel_empty_report_name_mgs()); + return; + } else if (doesReportProfileNameExist(reportName)) { + JOptionPane.showMessageDialog(WindowManager.getDefault().getMainWindow(), Bundle.CommandLineIngestSettingPanel_existing_report_name_mgs()); + return; + } + } + this.getParent().setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); - doReportWizard(getReportingConfigName(), DISPLAY_CASE_SPECIFIC_DATA, RUN_REPORTS); + doReportWizard(reportName, DISPLAY_CASE_SPECIFIC_DATA, RUN_REPORTS); + + setupReportList(); + + if (((DefaultComboBoxModel) reportProfileCB.getModel()).getIndexOf(reportName) >= 0) { + reportProfileCB.setSelectedItem(reportName); + } + this.getParent().setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); }//GEN-LAST:event_bnEditReportSettingsActionPerformed @@ -181,8 +320,9 @@ public class CommandLineIngestSettingsPanel extends javax.swing.JPanel { // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton bnEditIngestSettings; private javax.swing.JButton bnEditReportSettings; - private javax.swing.JLabel jLabelDescription; + private javax.swing.JComboBox ingestProfileCB; + private javax.swing.JTextPane jTextPane1; private javax.swing.JPanel nodePanel; - private javax.swing.JScrollPane nodeScrollPane; + private javax.swing.JComboBox reportProfileCB; // End of variables declaration//GEN-END:variables } diff --git a/Core/src/org/sleuthkit/autopsy/commandlineingest/CommandLineOptionProcessor.java b/Core/src/org/sleuthkit/autopsy/commandlineingest/CommandLineOptionProcessor.java index f23bd5f483..209c62f878 100755 --- a/Core/src/org/sleuthkit/autopsy/commandlineingest/CommandLineOptionProcessor.java +++ b/Core/src/org/sleuthkit/autopsy/commandlineingest/CommandLineOptionProcessor.java @@ -51,7 +51,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 final Option generateReportsOption = Option.optionalArgument('g', "generateReports"); private boolean runFromCommandLine = false; @@ -59,7 +59,7 @@ public class CommandLineOptionProcessor extends OptionProcessor { final static String CASETYPE_MULTI = "multi"; final static String CASETYPE_SINGLE = "single"; - + @Override protected Set