Cherry-picked commit edc6ed58587ddb12c7abecf536ef8794ddc3bfad from ingest-config branch

This commit is contained in:
Richard Cordovano 2013-08-06 17:08:01 -04:00
parent aa43c9de84
commit 9a26d45f19
6 changed files with 324 additions and 339 deletions

View File

@ -0,0 +1,153 @@
/*
* Autopsy Forensic Browser
*
* Copyright 2013 Basis Technology Corp.
* Contact: carrier <at> sleuthkit <dot> 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.casemodule;
import java.util.ArrayList;
import java.util.List;
import javax.swing.JPanel;
import org.sleuthkit.autopsy.coreutils.ModuleSettings;
import org.sleuthkit.autopsy.ingest.IngestDialogPanel;
import static org.sleuthkit.autopsy.ingest.IngestDialogPanel.DISABLED_MOD;
import static org.sleuthkit.autopsy.ingest.IngestDialogPanel.PARSE_UNALLOC;
import org.sleuthkit.autopsy.ingest.IngestManager;
import org.sleuthkit.autopsy.ingest.IngestModuleAbstract;
import org.sleuthkit.datamodel.Content;
/**
*
*/
public class GeneralIngestConfigurator implements IngestConfigurator {
private List<Content> contentToIngest;
private IngestManager manager;
private IngestDialogPanel ingestDialogPanel;
private String moduleContext;
public GeneralIngestConfigurator(String moduleContext) {
this.moduleContext = moduleContext;
ingestDialogPanel = new IngestDialogPanel();
manager = IngestManager.getDefault();
reload();
}
@Override
public JPanel getIngestConfigPanel() {
return ingestDialogPanel;
}
@Override
public void setContent(List<Content> inputContent) {
this.contentToIngest = inputContent;
}
@Override
public void start() {
//pick the modules
List<IngestModuleAbstract> modulesToStart = ingestDialogPanel.getModulesToStart();
if (!modulesToStart.isEmpty()) {
manager.execute(modulesToStart, contentToIngest);
}
//update ingest proc. unalloc space
manager.setProcessUnallocSpace(ingestDialogPanel.processUnallocSpaceEnabled());
}
@Override
public void save() {
// Save the current module
IngestModuleAbstract currentModule = ingestDialogPanel.getCurrentIngestModule();
if (currentModule != null && currentModule.hasSimpleConfiguration()) {
currentModule.saveSimpleConfiguration();
}
// create a list of disabled modules
List<IngestModuleAbstract> disabledModules = IngestManager.getDefault().enumerateAllModules();
disabledModules.removeAll(ingestDialogPanel.getModulesToStart());
// create a csv list
String disabledModulesCsv = moduleListToCsv(disabledModules);
ModuleSettings.setConfigSetting(moduleContext, DISABLED_MOD, disabledModulesCsv);
String processUnalloc = Boolean.toString(ingestDialogPanel.processUnallocSpaceEnabled());
ModuleSettings.setConfigSetting(moduleContext, PARSE_UNALLOC, processUnalloc);
}
public static String moduleListToCsv(List<IngestModuleAbstract> lst) {
if (lst == null || lst.isEmpty()) {
return "";
}
StringBuilder sb = new StringBuilder();
for (int i = 0; i < lst.size() - 1; ++i) {
sb.append(lst.get(i).getName()).append(", ");
}
// and the last one
sb.append(lst.get(lst.size() - 1).getName());
return sb.toString();
}
public static List<IngestModuleAbstract> csvToModuleList(String csv) {
List<IngestModuleAbstract> modules = new ArrayList<>();
if (csv == null || csv.isEmpty()) {
return modules;
}
String[] moduleNames = csv.split(", ");
List<IngestModuleAbstract> allModules = IngestManager.getDefault().enumerateAllModules();
for (String moduleName : moduleNames) {
for (IngestModuleAbstract module : allModules) {
if (moduleName.equals(module.getName())) {
modules.add(module);
break;
}
}
}
return modules;
}
@Override
public void reload() {
// get the csv list of disabled modules
String disabledModulesCsv = ModuleSettings.getConfigSetting(moduleContext, DISABLED_MOD);
// create a list of modules from it
List<IngestModuleAbstract> disabledModules = csvToModuleList(disabledModulesCsv);
// tell th ingestDialogPanel to unselect these modules
ingestDialogPanel.setDisabledModules(disabledModules);
boolean processUnalloc = Boolean.parseBoolean(ModuleSettings.getConfigSetting(moduleContext, PARSE_UNALLOC));
ingestDialogPanel.setProcessUnallocSpaceEnabled(processUnalloc);
}
@Override
public boolean isIngestRunning() {
return manager.isIngestRunning();
}
}

View File

@ -19,12 +19,17 @@
package org.sleuthkit.autopsy.coreutils; package org.sleuthkit.autopsy.coreutils;
import java.io.*; import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.Properties; import java.util.Properties;
import java.util.Set; import java.util.Set;
import java.util.logging.Level; import java.util.logging.Level;
/** /**
* This class contains the framework to read, add, update, and remove * This class contains the framework to read, add, update, and remove
* from the property files located at %USERDIR%/Config/x.properties * from the property files located at %USERDIR%/Config/x.properties
@ -35,12 +40,8 @@ public class ModuleSettings {
private final static String moduleDirPath = PlatformUtil.getUserConfigDirectory(); private final static String moduleDirPath = PlatformUtil.getUserConfigDirectory();
public static final String MAIN_SETTINGS = "Case"; public static final String MAIN_SETTINGS = "Case";
/** the constructor */ /** the constructor */
private ModuleSettings() { private ModuleSettings() {}
}
/** /**
* Makes a new config file of the specified name. Do not include the extension. * Makes a new config file of the specified name. Do not include the extension.
@ -162,8 +163,6 @@ public class ModuleSettings {
} }
} }
/** /**
* Sets the given properties file to the given setting map. * Sets the given properties file to the given setting map.
* @param moduleName - The name of the module to be written to. * @param moduleName - The name of the module to be written to.
@ -216,13 +215,11 @@ public class ModuleSettings {
} }
} }
/** /**
* Removes the given key from the given properties file. * Removes the given key from the given properties file.
* @param moduleName - The name of the properties file to be modified. * @param moduleName - The name of the properties file to be modified.
* @param key - the name of the key to remove. * @param key - the name of the key to remove.
*/ */
public static synchronized void removeProperty(String moduleName, String key){ public static synchronized void removeProperty(String moduleName, String key){
try{ try{
if(getConfigSetting(moduleName, key) != null){ if(getConfigSetting(moduleName, key) != null){
@ -268,5 +265,4 @@ public class ModuleSettings {
return new File(getPropertyPath(moduleName)); return new File(getPropertyPath(moduleName));
} }
} }
} }

View File

@ -1,7 +1,7 @@
/* /*
* Autopsy Forensic Browser * Autopsy Forensic Browser
* *
* Copyright 2011 Basis Technology Corp. * Copyright 2013 Basis Technology Corp.
* Contact: carrier <at> sleuthkit <dot> org * Contact: carrier <at> sleuthkit <dot> org
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
@ -26,36 +26,35 @@ import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter; import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent; import java.awt.event.WindowEvent;
import java.util.List; import java.util.List;
import org.sleuthkit.autopsy.coreutils.Logger;
import javax.swing.BoxLayout; import javax.swing.BoxLayout;
import javax.swing.JButton; import javax.swing.JButton;
import javax.swing.JDialog; import javax.swing.JDialog;
import javax.swing.JFrame; import javax.swing.JFrame;
import javax.swing.JPanel; import javax.swing.JPanel;
import org.sleuthkit.datamodel.Content; import org.sleuthkit.datamodel.Content;
import org.sleuthkit.autopsy.casemodule.GeneralIngestConfigurator;
import org.sleuthkit.autopsy.casemodule.IngestConfigurator;
/** /**
* IngestDialog shown on Case.CASE_ADD_IMAGE property change * IngestDialog shown on Case.CASE_ADD_IMAGE property change
*/ */
public class IngestDialog extends JDialog { public class IngestDialog extends JDialog {
private static final String MODULE_CONTEXT = "MainIngest";
private static final String TITLE = "Ingest Modules"; private static final String TITLE = "Ingest Modules";
private static Dimension DIMENSIONS = new Dimension(500, 300); private static Dimension DIMENSIONS = new Dimension(500, 300);
private IngestDialogPanel panel = null; private IngestConfigurator ingestConfigurator;
private static final Logger logger = Logger.getLogger(IngestDialog.class.getName());
public IngestDialog(JFrame frame, String title, boolean modal) { public IngestDialog(JFrame frame, String title, boolean modal) {
super(frame, title, modal); super(frame, title, modal);
panel = new IngestDialogPanel(); ingestConfigurator = new GeneralIngestConfigurator(MODULE_CONTEXT);
ingestConfigurator.reload();
} }
public IngestDialog(){ public IngestDialog(){
this(new JFrame(TITLE), TITLE, true); this(new JFrame(TITLE), TITLE, true);
} }
/** /**
* Shows the Ingest dialog. * Shows the Ingest dialog.
*/ */
@ -71,17 +70,14 @@ public class IngestDialog extends JDialog {
// set the location of the popUp Window on the center of the screen // set the location of the popUp Window on the center of the screen
setLocation((screenDimension.width - w) / 2, (screenDimension.height - h) / 2); setLocation((screenDimension.width - w) / 2, (screenDimension.height - h) / 2);
panel.reload(); // reload the simple panel add(ingestConfigurator.getIngestConfigPanel(), BorderLayout.PAGE_START);
add(panel, BorderLayout.PAGE_START);
JButton startButton = new JButton("Start"); JButton startButton = new JButton("Start");
JButton closeButton = new JButton("Close"); JButton closeButton = new JButton("Close");
startButton.addActionListener(new ActionListener() { startButton.addActionListener(new ActionListener() {
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
ingestConfigurator.start();
panel.save();
panel.start();
close(); close();
} }
}); });
@ -89,7 +85,7 @@ public class IngestDialog extends JDialog {
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
panel.save(); ingestConfigurator.save();
close(); close();
} }
}); });
@ -97,7 +93,7 @@ public class IngestDialog extends JDialog {
@Override @Override
public void windowClosing(WindowEvent e) { public void windowClosing(WindowEvent e) {
panel.save(); ingestConfigurator.save();
close(); close();
} }
}); });
@ -115,10 +111,9 @@ public class IngestDialog extends JDialog {
} }
public void setContent(List<Content> inputContent) { public void setContent(List<Content> inputContent) {
panel.setContent(inputContent); ingestConfigurator.setContent(inputContent);
} }
/** /**
* Closes the Ingest dialog * Closes the Ingest dialog
*/ */
@ -126,6 +121,4 @@ public class IngestDialog extends JDialog {
setVisible(false); setVisible(false);
dispose(); dispose();
} }
} }

View File

@ -1,7 +1,7 @@
/* /*
* Autopsy Forensic Browser * Autopsy Forensic Browser
* *
* Copyright 2011 Basis Technology Corp. * Copyright 2013 Basis Technology Corp.
* Contact: carrier <at> sleuthkit <dot> org * Contact: carrier <at> sleuthkit <dot> org
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
@ -18,24 +18,15 @@
*/ */
package org.sleuthkit.autopsy.ingest; package org.sleuthkit.autopsy.ingest;
import java.awt.Color;
import java.awt.Component; import java.awt.Component;
import java.awt.Graphics;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter; import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent; import java.awt.event.WindowEvent;
import java.beans.PropertyChangeEvent; import java.util.AbstractMap;
import java.beans.PropertyChangeListener;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.logging.Level;
import org.sleuthkit.autopsy.coreutils.Logger;
import javax.swing.JPanel;
import javax.swing.JTable; import javax.swing.JTable;
import javax.swing.ListSelectionModel; import javax.swing.ListSelectionModel;
import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionEvent;
@ -43,80 +34,47 @@ import javax.swing.event.ListSelectionListener;
import javax.swing.table.AbstractTableModel; import javax.swing.table.AbstractTableModel;
import javax.swing.table.DefaultTableCellRenderer; import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.TableColumn; import javax.swing.table.TableColumn;
import org.openide.util.lookup.ServiceProvider;
import org.sleuthkit.autopsy.casemodule.IngestConfigurator;
import org.sleuthkit.autopsy.corecomponents.AdvancedConfigurationDialog; import org.sleuthkit.autopsy.corecomponents.AdvancedConfigurationDialog;
import org.sleuthkit.autopsy.coreutils.ModuleSettings;
import org.sleuthkit.autopsy.ingest.IngestModuleAbstract.ModuleType;
import org.sleuthkit.datamodel.Content;
import org.sleuthkit.datamodel.TskCoreException;
/** /**
* main configuration panel for all ingest modules, reusable JPanel component * main configuration panel for all ingest modules, reusable JPanel component
*/ */
@ServiceProvider(service = IngestConfigurator.class) public class IngestDialogPanel extends javax.swing.JPanel {
public class IngestDialogPanel extends javax.swing.JPanel implements IngestConfigurator {
private IngestManager manager = null;
private List<IngestModuleAbstract> modules;
private IngestModuleAbstract currentModule; private IngestModuleAbstract currentModule;
private Map<String, Boolean> moduleStates;
private ModulesTableModel tableModel; private ModulesTableModel tableModel;
private static final Logger logger = Logger.getLogger(IngestDialogPanel.class.getName());
public static final String DISABLED_MOD = "Disabled_Ingest_Modules"; public static final String DISABLED_MOD = "Disabled_Ingest_Modules";
public static final String PARSE_UNALLOC = "Process_Unallocated_Space"; public static final String PARSE_UNALLOC = "Process_Unallocated_Space";
// The input content that's just been added to the database
private List<Content> inputContent;
// private static IngestDialogPanel instance = null;
/** /**
* Creates new form IngestDialogPanel * Creates new form IngestDialogPanel
*/ */
public IngestDialogPanel() { public IngestDialogPanel() {
tableModel = new ModulesTableModel(); tableModel = new ModulesTableModel();
modules = new ArrayList<IngestModuleAbstract>();
moduleStates = new HashMap<String, Boolean>();
initComponents(); initComponents();
customizeComponents(); customizeComponents();
} }
private void loadModules() { public IngestModuleAbstract getCurrentIngestModule() {
this.modules.clear(); return currentModule;
//this.moduleStates.clear(); maintain the state
Collection<IngestModuleDataSource> imageModules = manager.enumerateDataSourceModules();
for (final IngestModuleDataSource module : imageModules) {
addModule(module);
} }
Collection<IngestModuleAbstractFile> fsModules = manager.enumerateAbstractFileModules();
for (final IngestModuleAbstractFile module : fsModules) { public List<IngestModuleAbstract> getModulesToStart() {
addModule(module); return tableModel.getSelectedModules();
} }
public boolean processUnallocSpaceEnabled() {
return processUnallocCheckbox.isSelected();
} }
private void customizeComponents() { private void customizeComponents() {
modulesTable.setModel(tableModel); modulesTable.setModel(tableModel);
this.manager = IngestManager.getDefault();
loadModules();
try {
IngestModuleLoader.getDefault().addModulesReloadedListener(new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
if (evt.getPropertyName().equals(IngestModuleLoader.Event.ModulesReloaded.toString())) {
loadModules();
}
}
});
} catch (IngestModuleLoaderException ex) {
logger.log(Level.SEVERE, "Could not initialize ingest module loader to listen for module config changes", ex);
}
modulesTable.setTableHeader(null); modulesTable.setTableHeader(null);
modulesTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); modulesTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
//custom renderer for tooltips //custom renderer for tooltips
ModulesTableRenderer renderer = new ModulesTableRenderer(); ModulesTableRenderer renderer = new ModulesTableRenderer();
//customize column witdhs //customize column witdhs
final int width = modulesScrollPane.getPreferredSize().width; final int width = modulesScrollPane.getPreferredSize().width;
TableColumn column = null; TableColumn column = null;
@ -135,40 +93,30 @@ public class IngestDialogPanel extends javax.swing.JPanel implements IngestConfi
public void valueChanged(ListSelectionEvent e) { public void valueChanged(ListSelectionEvent e) {
ListSelectionModel listSelectionModel = (ListSelectionModel) e.getSource(); ListSelectionModel listSelectionModel = (ListSelectionModel) e.getSource();
if (!listSelectionModel.isSelectionEmpty()) { if (!listSelectionModel.isSelectionEmpty()) {
save();
int index = listSelectionModel.getMinSelectionIndex(); int index = listSelectionModel.getMinSelectionIndex();
currentModule = modules.get(index); currentModule = tableModel.getModule(index);
reload();
// add the module-specific configuration panel, if there is one
simplePanel.removeAll();
if (currentModule.hasSimpleConfiguration()) {
simplePanel.add(currentModule.getSimpleConfiguration());
}
simplePanel.revalidate();
simplePanel.repaint();
advancedButton.setEnabled(currentModule.hasAdvancedConfiguration()); advancedButton.setEnabled(currentModule.hasAdvancedConfiguration());
} else { } else {
currentModule = null; currentModule = null;
} }
} }
}); });
processUnallocCheckbox.setSelected(manager.getProcessUnallocSpace());
} }
private void setProcessUnallocSpaceEnabled(boolean enabled) { public void setProcessUnallocSpaceEnabled(final boolean enabled) {
processUnallocCheckbox.setEnabled(enabled); processUnallocCheckbox.setSelected(enabled);
} }
@Override public void setDisabledModules(List<IngestModuleAbstract> disabledModules) {
public void paint(Graphics g) { tableModel.setUnselectedModules(disabledModules);
super.paint(g);
if (manager.isIngestRunning()) {
setProcessUnallocSpaceEnabled(false);
} else {
setProcessUnallocSpaceEnabled(true);
}
}
private void addModule(IngestModuleAbstract module) {
final String moduleName = module.getName();
modules.add(module);
moduleStates.put(moduleName, true);
} }
/** /**
@ -311,22 +259,19 @@ public class IngestDialogPanel extends javax.swing.JPanel implements IngestConfi
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
dialog.close(); dialog.close();
currentModule.saveAdvancedConfiguration(); currentModule.saveAdvancedConfiguration();
reload();
} }
}); });
dialog.addWindowListener(new WindowAdapter() { dialog.addWindowListener(new WindowAdapter() {
@Override @Override
public void windowClosing(WindowEvent e) { public void windowClosing(WindowEvent e) {
dialog.close(); dialog.close();
reload();
} }
}); });
save(); // save the simple panel dialog.display(currentModule.getAdvancedConfiguration());
dialog.display(currentModule.getAdvancedConfiguration(null));
}//GEN-LAST:event_advancedButtonActionPerformed }//GEN-LAST:event_advancedButtonActionPerformed
private void processUnallocCheckboxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_processUnallocCheckboxActionPerformed private void processUnallocCheckboxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_processUnallocCheckboxActionPerformed
// TODO add your handling code here: // nothing to do here
}//GEN-LAST:event_processUnallocCheckboxActionPerformed }//GEN-LAST:event_processUnallocCheckboxActionPerformed
// Variables declaration - do not modify//GEN-BEGIN:variables // Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton advancedButton; private javax.swing.JButton advancedButton;
@ -343,9 +288,18 @@ public class IngestDialogPanel extends javax.swing.JPanel implements IngestConfi
private class ModulesTableModel extends AbstractTableModel { private class ModulesTableModel extends AbstractTableModel {
private List<Map.Entry<IngestModuleAbstract, Boolean>>moduleData = new ArrayList<>();
public ModulesTableModel() {
List<IngestModuleAbstract> modules = IngestManager.getDefault().enumerateAllModules();
for (IngestModuleAbstract ingestModuleAbstract : modules) {
moduleData.add(new AbstractMap.SimpleEntry<>(ingestModuleAbstract, Boolean.TRUE));
}
}
@Override @Override
public int getRowCount() { public int getRowCount() {
return modules.size(); return moduleData.size();
} }
@Override @Override
@ -355,11 +309,11 @@ public class IngestDialogPanel extends javax.swing.JPanel implements IngestConfi
@Override @Override
public Object getValueAt(int rowIndex, int columnIndex) { public Object getValueAt(int rowIndex, int columnIndex) {
String name = modules.get(rowIndex).getName(); Map.Entry<IngestModuleAbstract, Boolean> entry = moduleData.get(rowIndex);
if (columnIndex == 0) { if (columnIndex == 0) {
return moduleStates.get(name); return entry.getValue();
} else { } else {
return name; return entry.getKey().getName();
} }
} }
@ -371,8 +325,7 @@ public class IngestDialogPanel extends javax.swing.JPanel implements IngestConfi
@Override @Override
public void setValueAt(Object aValue, int rowIndex, int columnIndex) { public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
if (columnIndex == 0) { if (columnIndex == 0) {
moduleStates.put((String) getValueAt(rowIndex, 1), (Boolean) aValue); moduleData.get(rowIndex).setValue((Boolean)aValue);
} }
} }
@ -380,125 +333,69 @@ public class IngestDialogPanel extends javax.swing.JPanel implements IngestConfi
public Class<?> getColumnClass(int c) { public Class<?> getColumnClass(int c) {
return getValueAt(0, c).getClass(); return getValueAt(0, c).getClass();
} }
}
List<IngestModuleAbstract> getModulesToStart() { public List<IngestModuleAbstract> getSelectedModules() {
List<IngestModuleAbstract> modulesToStart = new ArrayList<IngestModuleAbstract>(); List<IngestModuleAbstract> selectedModules = new ArrayList<>();
for (IngestModuleAbstract module : modules) { for (Map.Entry<IngestModuleAbstract, Boolean> entry : moduleData) {
boolean moduleEnabled = moduleStates.get(module.getName()); if (entry.getValue().booleanValue()) {
if (moduleEnabled) { selectedModules.add(entry.getKey());
modulesToStart.add(module);
} }
} }
return modulesToStart; return selectedModules;
}
private boolean processUnallocSpaceEnabled() {
return processUnallocCheckbox.isEnabled();
} }
/** /**
* To be called whenever the next, close, or start buttons are pressed. * Sets the given modules as selected in the modules table
* * @param selectedModules
*/ */
@Override public void setSelectedModules(List<IngestModuleAbstract> selectedModules) {
public void save() { // unselect all modules
// Save the current module for (Map.Entry<IngestModuleAbstract, Boolean> entry : moduleData) {
if (currentModule != null && currentModule.hasSimpleConfiguration()) { entry.setValue(Boolean.FALSE);
currentModule.saveSimpleConfiguration();
} }
// Save this panel
List<String> modulesDisabled = new ArrayList<String>();
for (int i = 0; i < modulesTable.getRowCount(); i++) {
// Column 0 is always the module's checkbox (which is retreived as a boolean)
Boolean enabled = (Boolean) modulesTable.getValueAt(i, 0);
if (!enabled) {
// Column 1 is always the module name
String moduleName = (String) modulesTable.getValueAt(i, 1);
modulesDisabled.add(moduleName);
}
}
// Add all the enabled modules to the properties separated by a coma
String list = "";
for (int i = 0; i < modulesDisabled.size(); i++) {
list += modulesDisabled.get(i);
if (i + 1 < modulesDisabled.size()) {
list += ", ";
}
}
ModuleSettings.setConfigSetting(IngestManager.MODULE_PROPERTIES, DISABLED_MOD, list);
String processUnalloc = Boolean.toString(processUnallocCheckbox.isSelected());
ModuleSettings.setConfigSetting(IngestManager.MODULE_PROPERTIES, PARSE_UNALLOC, processUnalloc);
// select only the given modules
for (IngestModuleAbstract selectedModule : selectedModules) {
getEntryForModule(selectedModule).setValue(Boolean.TRUE);
}
// tell everyone about it
fireTableDataChanged();
} }
/** /**
* Called when the dialog needs to be reloaded. Most commonly used to * Sets the given modules as NOT selected in the modules table
* refresh the simple panel. * @param selectedModules
*
* Called every time this panel is displayed.
*/ */
@Override public void setUnselectedModules(List<IngestModuleAbstract> unselectedModules) {
public void reload() { // select all modules
// Reload the simple panel for (Map.Entry<IngestModuleAbstract, Boolean> entry : moduleData) {
if (this.modulesTable.getSelectedRow() != -1) { entry.setValue(Boolean.TRUE);
simplePanel.removeAll();
if (currentModule.hasSimpleConfiguration()) {
simplePanel.add(currentModule.getSimpleConfiguration(null));
}
simplePanel.revalidate();
simplePanel.repaint();
}
// Reload this panel
String list = ModuleSettings.getConfigSetting(IngestManager.MODULE_PROPERTIES, DISABLED_MOD);
if (list != null) { // if no property is found, list will be null
List<String> modulesDisabled = new ArrayList<String>(Arrays.asList(list.split(", ")));
// For every row, see if that module name is in the ArrayList
for (int i = 0; i < modulesTable.getRowCount(); i++) {
String moduleName = (String) modulesTable.getValueAt(i, 1);
if (modulesDisabled.contains(moduleName)) {
modulesTable.setValueAt(false, i, 0); // we found it, disable the module
} else {
modulesTable.setValueAt(true, i, 0); // not on disabled list, or a new module, enable it
}
}
}
String processUnalloc = ModuleSettings.getConfigSetting(IngestManager.MODULE_PROPERTIES, PARSE_UNALLOC);
if (processUnalloc != null) {
processUnallocCheckbox.setSelected(Boolean.parseBoolean(processUnalloc));
}
} }
@Override // unselect only the given modules
public JPanel getIngestConfigPanel() { for (IngestModuleAbstract unselectedModule : unselectedModules) {
this.reload(); getEntryForModule(unselectedModule).setValue(Boolean.FALSE);
return this;
} }
@Override // tell everyone about it
public void setContent(List<Content> inputContent) { fireTableDataChanged();
this.inputContent = inputContent;
} }
@Override public IngestModuleAbstract getModule(int row) {
public void start() { return moduleData.get(row).getKey();
//pick the modules
List<IngestModuleAbstract> modulesToStart = getModulesToStart();
//update ingest proc. unalloc space
if (processUnallocSpaceEnabled()) {
manager.setProcessUnallocSpace(processUnallocCheckbox.isSelected());
} }
if (!modulesToStart.isEmpty()) { private Map.Entry<IngestModuleAbstract, Boolean> getEntryForModule(IngestModuleAbstract module) {
manager.execute(modulesToStart, inputContent); Map.Entry<IngestModuleAbstract, Boolean> entry = null;
for (Map.Entry<IngestModuleAbstract, Boolean> anEntry : moduleData) {
if (anEntry.getKey().equals(module)) {
entry = anEntry;
break;
} }
} }
return entry;
@Override }
public boolean isIngestRunning() {
return manager.isIngestRunning();
} }
/** /**
@ -506,57 +403,26 @@ public class IngestDialogPanel extends javax.swing.JPanel implements IngestConfi
*/ */
private class ModulesTableRenderer extends DefaultTableCellRenderer { private class ModulesTableRenderer extends DefaultTableCellRenderer {
List<String> tooltips = new ArrayList<>();
public ModulesTableRenderer() {
List<IngestModuleAbstract> modules = IngestManager.getDefault().enumerateAllModules();
for (IngestModuleAbstract ingestModuleAbstract : modules) {
tooltips.add(ingestModuleAbstract.getDescription());
}
}
@Override @Override
public Component getTableCellRendererComponent( public Component getTableCellRendererComponent(
JTable table, Object value, JTable table, Object value,
boolean isSelected, boolean hasFocus, boolean isSelected, boolean hasFocus,
int row, int column) { int row, int column) {
super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
final Component cell = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
if (column == 1) { if (column == 1) {
//String moduleName = (String) table.getModel().getValueAt(row, column); setToolTipText(tooltips.get(row));
IngestModuleAbstract module = modules.get(row);
String moduleDescr = module.getDescription();
String toolTip = moduleDescr;
if (inputContent != null && module.getType().equals(ModuleType.DataSource)) {
//DataSource module accepts only data source, does not work on any child
//show warning to user and set fg red for that module
boolean isDataSource = true;
for (Content content : inputContent) {
try {
if (content.getParent() != null) {
isDataSource = false;
break;
} }
} catch (TskCoreException e) { return this;
logger.log(Level.SEVERE, "Error checking if module input content is parentless data source", e);
}
}
if (! isDataSource ) {
cell.setForeground(Color.red);
toolTip = toolTip + "<br />WARNING: this module will not run on current selection because it operates only on root-level data-source (such as Image, Filesets).";
}
else {
cell.setForeground(Color.black);
}
} //end data source
else {
cell.setForeground(Color.black);
}
//
setToolTipText("<html>" + toolTip+ "</html>");
}
return cell;
} }
} }
} }

View File

@ -1,7 +1,7 @@
/* /*
* Autopsy Forensic Browser * Autopsy Forensic Browser
* *
* Copyright 2012 Basis Technology Corp. * Copyright 2013 Basis Technology Corp.
* Contact: carrier <at> sleuthkit <dot> org * Contact: carrier <at> sleuthkit <dot> org
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
@ -154,8 +154,6 @@ public class IngestManager {
} catch (IngestModuleLoaderException ex) { } catch (IngestModuleLoaderException ex) {
logger.log(Level.SEVERE, "Error getting module loader"); logger.log(Level.SEVERE, "Error getting module loader");
} }
} }
/** /**
@ -243,7 +241,6 @@ public class IngestManager {
if (ui != null) { if (ui != null) {
ui.restoreMessages(); ui.restoreMessages();
} }
} }
/** /**
@ -346,8 +343,6 @@ public class IngestManager {
} }
} }
} }
//}
//AbstractFile ingester //AbstractFile ingester
boolean startAbstractFileIngester = false; boolean startAbstractFileIngester = false;
@ -421,7 +416,6 @@ public class IngestManager {
List<IngestDataSourceThread> toStop = new ArrayList<IngestDataSourceThread>(); List<IngestDataSourceThread> toStop = new ArrayList<IngestDataSourceThread>();
toStop.addAll(dataSourceIngesters); toStop.addAll(dataSourceIngesters);
for (IngestDataSourceThread dataSourceWorker : toStop) { for (IngestDataSourceThread dataSourceWorker : toStop) {
IngestModuleDataSource s = dataSourceWorker.getModule(); IngestModuleDataSource s = dataSourceWorker.getModule();
@ -440,7 +434,6 @@ public class IngestManager {
logger.log(Level.WARNING, "Exception while stopping module: " + s.getName(), e); logger.log(Level.WARNING, "Exception while stopping module: " + s.getName(), e);
} }
} }
} }
logger.log(Level.INFO, "stopped all"); logger.log(Level.INFO, "stopped all");
@ -545,7 +538,6 @@ public class IngestManager {
return module.hasBackgroundJobsRunning(); return module.hasBackgroundJobsRunning();
} }
} else { } else {
//data source module //data source module
synchronized (this) { synchronized (this) {
@ -570,10 +562,7 @@ public class IngestManager {
return false; return false;
} }
} }
} }
} }
/** /**
@ -607,7 +596,7 @@ public class IngestManager {
* *
* @param processUnallocSpace * @param processUnallocSpace
*/ */
void setProcessUnallocSpace(boolean processUnallocSpace) { public void setProcessUnallocSpace(boolean processUnallocSpace) {
this.processUnallocSpace = processUnallocSpace; this.processUnallocSpace = processUnallocSpace;
} }
@ -672,6 +661,13 @@ public class IngestManager {
return moduleLoader.getAbstractFileIngestModules(); return moduleLoader.getAbstractFileIngestModules();
} }
public List<IngestModuleAbstract> enumerateAllModules() {
List<IngestModuleAbstract> modules = new ArrayList<>();
modules.addAll(enumerateDataSourceModules());
modules.addAll(enumerateAbstractFileModules());
return modules;
}
//data source worker to remove itself when complete or interrupted //data source worker to remove itself when complete or interrupted
void removeDataSourceIngestWorker(IngestDataSourceThread worker) { void removeDataSourceIngestWorker(IngestDataSourceThread worker) {
//remove worker //remove worker
@ -697,7 +693,6 @@ public class IngestManager {
IngestManagerStats() { IngestManagerStats() {
errors = new HashMap<IngestModuleAbstract, Integer>(); errors = new HashMap<IngestModuleAbstract, Integer>();
} }
/** /**
@ -775,19 +770,8 @@ public class IngestManager {
public String toHtmlString() { public String toHtmlString() {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
sb.append("<html>"); sb.append("<html>");
sb.append("Ingest time: ").append(getTotalTimeString()).append("<br />"); sb.append("Ingest time: ").append(getTotalTimeString()).append("<br />");
sb.append("Total errors: ").append(errorsTotal).append("<br />"); sb.append("Total errors: ").append(errorsTotal).append("<br />");
/*
if (errorsTotal > 0) {
sb.append("Errors per module:");
for (IngestModuleAbstract module : errors.keySet()) {
final int errorsModule = errors.get(module);
sb.append("\t").append(module.getName()).append(": ").append(errorsModule).append("<br />");
}
}
* */
sb.append("</html>"); sb.append("</html>");
return sb.toString(); return sb.toString();
} }

View File

@ -146,34 +146,27 @@ public abstract class IngestModuleAbstract {
public void saveAdvancedConfiguration() {} public void saveAdvancedConfiguration() {}
/** /**
* Returns a panel that displays the simple (run-time) configuration * Returns a panel that displays the simple (run-time) configuration.
* for the given configuration context (such as pipeline instance).
* This is presented to the user before ingest starts and only basic * This is presented to the user before ingest starts and only basic
* settings should be given here. Use the advanced (general) configuration * settings should be given here. use the advanced (general) configuration
* panel for more in-depth interfaces. * panel for more in-depth interfaces.
* The module (or its configuration controller object) is responsible for preserving / saving its configuration state * The module is responsible for preserving / saving its configuration state
* In addition, saveSimpleConfiguration() can be used as the trigger. * In addition, saveSimpleConfiguration() can be used
* *
* @param context the configuration context to use in the panel
* @return JPanel containing basic configuration widgets or null if simple configuration is not available * @return JPanel containing basic configuration widgets or null if simple configuration is not available
*/ */
public javax.swing.JPanel getSimpleConfiguration(String context) { public javax.swing.JPanel getSimpleConfiguration() {
return null; return null;
} }
/** /**
* Returns a panel that displays the advanced (run-time) configuration * Implements advanced module configuration exposed to the user before ingest starts
* for the given configuration context (such as pipeline instance). * The module is responsible for preserving / saving its configuration state
* Implements advanced module configuration exposed to the user before ingest starts. * In addition, saveAdvancedConfiguration() can be used
* *
* The module (or its configuration controller object) * @return JPanel containing basic configuration widgets or null if advanced configuration is not available
* is responsible for preserving / saving its configuration state
* In addition, saveAdvancedConfiguration() can be used as the trigger.
*
* @param context the configuration context to use in the panel
* @return JPanel containing advanced configuration widgets or null if advanced configuration is not available
*/ */
public javax.swing.JPanel getAdvancedConfiguration(String context) { public javax.swing.JPanel getAdvancedConfiguration() {
return null; return null;
}; };
} }