From aa32aa261ace5ff41fec43bbcbb15a9167f851f3 Mon Sep 17 00:00:00 2001 From: "Samuel H. Kenyon" Date: Mon, 6 Jan 2014 21:48:30 -0500 Subject: [PATCH] Save and load from a new disabled modules list in the ingest properties config file. Loaded modules which are missing from the config file will be auto-added as enabled. --- .../ingest/GeneralIngestConfigurator.java | 47 +++++++++++++++++-- .../autopsy/ingest/IngestDialogPanel.java | 16 ++++++- 2 files changed, 58 insertions(+), 5 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/ingest/GeneralIngestConfigurator.java b/Core/src/org/sleuthkit/autopsy/ingest/GeneralIngestConfigurator.java index eaeb0eefc6..33979e58e9 100644 --- a/Core/src/org/sleuthkit/autopsy/ingest/GeneralIngestConfigurator.java +++ b/Core/src/org/sleuthkit/autopsy/ingest/GeneralIngestConfigurator.java @@ -19,6 +19,7 @@ package org.sleuthkit.autopsy.ingest; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; import javax.swing.JPanel; import org.openide.util.lookup.ServiceProvider; @@ -29,6 +30,7 @@ import org.sleuthkit.datamodel.Content; public class GeneralIngestConfigurator implements IngestConfigurator { public static final String ENABLED_INGEST_MODULES_KEY = "Enabled_Ingest_Modules"; + public static final String DISABLED_INGEST_MODULES_KEY = "Disabled_Ingest_Modules"; public static final String PARSE_UNALLOC_SPACE_KEY = "Process_Unallocated_Space"; private List contentToIngest; private IngestManager manager; @@ -51,20 +53,53 @@ public class GeneralIngestConfigurator implements IngestConfigurator { private List loadSettingsForContext() { List messages = new ArrayList<>(); + List allModules = IngestManager.getDefault().enumerateAllModules(); // If there is no enabled ingest modules setting for this user, default to enabling all // of the ingest modules the IngestManager has loaded. if (ModuleSettings.settingExists(moduleContext, ENABLED_INGEST_MODULES_KEY) == false) { - String defaultSetting = moduleListToCsv(IngestManager.getDefault().enumerateAllModules()); + String defaultSetting = moduleListToCsv(allModules); ModuleSettings.setConfigSetting(moduleContext, ENABLED_INGEST_MODULES_KEY, defaultSetting); } + String[] enabledModuleNames = ModuleSettings.getConfigSetting(moduleContext, ENABLED_INGEST_MODULES_KEY).split(", "); + ArrayList enabledList = new ArrayList<>(Arrays.asList(enabledModuleNames)); + + // Check for modules that are missing from the config file + if (ModuleSettings.settingExists(moduleContext, DISABLED_INGEST_MODULES_KEY)) { + String[] disabledModuleNames = ModuleSettings.getConfigSetting(moduleContext, DISABLED_INGEST_MODULES_KEY).split(", "); + for (IngestModuleAbstract module : allModules) { + boolean found = false; + + // Check enabled first + for (String moduleName : enabledModuleNames) { + if (module.getName().equals(moduleName)) { + found = true; + break; + } + } + + // Then check disabled + if (!found) { + for (String moduleName : disabledModuleNames) { + if (module.getName().equals(moduleName)) { + found = true; + break; + } + } + } + + if (!found) { + enabledList.add(module.getName()); + //it will get saved to file later + } + } + } + // Get the enabled ingest modules setting, check for missing modules, and pass the setting to // the UI component. - List allModules = IngestManager.getDefault().enumerateAllModules(); - String[] enabledModuleNames = ModuleSettings.getConfigSetting(moduleContext, ENABLED_INGEST_MODULES_KEY).split(", "); List enabledModules = new ArrayList<>(); - for (String moduleName : enabledModuleNames) { + for (String moduleName : enabledList) { if (moduleName.equals("Thunderbird Parser") || moduleName.equals("MBox Parser")) { moduleName = "Email Parser"; @@ -112,6 +147,10 @@ public class GeneralIngestConfigurator implements IngestConfigurator { String enabledModulesCsvList = moduleListToCsv(ingestDialogPanel.getModulesToStart()); ModuleSettings.setConfigSetting(moduleContext, ENABLED_INGEST_MODULES_KEY, enabledModulesCsvList); + // Save the user's configuration of the set of disabled ingest modules. + String disabledModulesCsvList = moduleListToCsv(ingestDialogPanel.getDisabledModules()); + ModuleSettings.setConfigSetting(moduleContext, DISABLED_INGEST_MODULES_KEY, disabledModulesCsvList); + // Save the user's setting for the process unallocated space flag. String processUnalloc = Boolean.toString(ingestDialogPanel.processUnallocSpaceEnabled()); ModuleSettings.setConfigSetting(moduleContext, PARSE_UNALLOC_SPACE_KEY, processUnalloc); diff --git a/Core/src/org/sleuthkit/autopsy/ingest/IngestDialogPanel.java b/Core/src/org/sleuthkit/autopsy/ingest/IngestDialogPanel.java index 331c727576..198f19da13 100644 --- a/Core/src/org/sleuthkit/autopsy/ingest/IngestDialogPanel.java +++ b/Core/src/org/sleuthkit/autopsy/ingest/IngestDialogPanel.java @@ -60,7 +60,7 @@ public class IngestDialogPanel extends javax.swing.JPanel { this.context = context; } - + public IngestModuleAbstract getCurrentIngestModule() { return currentModule; } @@ -69,6 +69,10 @@ public class IngestDialogPanel extends javax.swing.JPanel { return tableModel.getSelectedModules(); } + public List getDisabledModules() { + return tableModel.getUnSelectedModules(); + } + public boolean processUnallocSpaceEnabled() { return processUnallocCheckbox.isSelected(); } @@ -350,6 +354,16 @@ public class IngestDialogPanel extends javax.swing.JPanel { return selectedModules; } + public List getUnSelectedModules() { + List unselectedModules = new ArrayList<>(); + for (Map.Entry entry : moduleData) { + if (!entry.getValue().booleanValue()) { + unselectedModules.add(entry.getKey()); + } + } + return unselectedModules; + } + /** * Sets the given modules as selected in the modules table * @param selectedModules