Merge pull request #1710 from mhmdfy/ingest-dir

Ingest dir
This commit is contained in:
Richard Cordovano 2015-11-12 13:33:12 -05:00
commit ea3484461b
4 changed files with 70 additions and 6 deletions

View File

@ -105,6 +105,14 @@ class DirectoryTreeFilterNode extends FilterNode {
Directory dir = this.getLookup().lookup(Directory.class);
if (dir != null) {
actions.add(ExtractAction.getInstance());
actions.add(new AbstractAction(
NbBundle.getMessage(this.getClass(), "DirectoryTreeFilterNode.action.runIngestMods.text")) {
@Override
public void actionPerformed(ActionEvent e) {
final RunIngestModulesDialog ingestDialog = new RunIngestModulesDialog(dir);
ingestDialog.display();
}
});
}
final Image img = this.getLookup().lookup(Image.class);

View File

@ -619,8 +619,6 @@ public final class DirectoryTreeTopComponent extends TopComponent implements Dat
DirectoryTreeTopComponent.this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
try {
// make sure dataResult is open, redundant?
//dataResult.open();
Node treeNode = DirectoryTreeTopComponent.this.getSelectedNode();
if (treeNode != null) {
DirectoryTreeFilterNode.OriginalNode origin = treeNode.getLookup().lookup(DirectoryTreeFilterNode.OriginalNode.class);

View File

@ -53,12 +53,24 @@ public class IngestJobSettings {
private static final String MODULE_SETTINGS_FILE_EXT = ".settings"; //NON-NLS
private static final Logger logger = Logger.getLogger(IngestJobSettings.class.getName());
private final String context;
private final IngestType ingestType;
private String moduleSettingsFolderPath;
private static final CharSequence pythonModuleSettingsPrefixCS = "org.python.proxies.".subSequence(0, "org.python.proxies.".length() - 1);
private final List<IngestModuleTemplate> moduleTemplates;
private boolean processUnallocatedSpace;
private final List<String> warnings;
// Determines which modeules to run
public enum IngestType {
// Run all modules
ALL_MODULES,
// Run only data source modules
DATA_SOURCE_ONLY,
// Run only files modules
FILES_ONLY
}
/**
* Constructs an ingest job settings object for a given context.
*
@ -66,6 +78,29 @@ public class IngestJobSettings {
*/
public IngestJobSettings(String context) {
this.context = context;
this.ingestType = IngestType.ALL_MODULES;
this.moduleTemplates = new ArrayList<>();
this.processUnallocatedSpace = Boolean.parseBoolean(IngestJobSettings.PROCESS_UNALLOC_SPACE_DEFAULT);
this.warnings = new ArrayList<>();
this.createSavedModuleSettingsFolder();
this.load();
}
/**
* Constructs an ingest job settings object for a given context.
*
* @param context The context identifier string.
* @param ingestType The type of modules ingest is running.
*/
public IngestJobSettings(String context, IngestType ingestType) {
this.ingestType = ingestType;
if (this.ingestType.equals(IngestType.ALL_MODULES)) {
this.context = context;
} else {
this.context = context + "." + this.ingestType.name();
}
this.moduleTemplates = new ArrayList<>();
this.processUnallocatedSpace = Boolean.parseBoolean(IngestJobSettings.PROCESS_UNALLOC_SPACE_DEFAULT);
this.warnings = new ArrayList<>();
@ -145,10 +180,10 @@ public class IngestJobSettings {
void setProcessUnallocatedSpace(boolean processUnallocatedSpace) {
this.processUnallocatedSpace = processUnallocatedSpace;
}
/**
* Returns the path to the ingest module settings folder.
*
*
* @return path to the module settings folder
*/
public Path getSavedModuleSettingsFolder(){
@ -178,8 +213,21 @@ public class IngestJobSettings {
* Get the ingest module factories discovered by the ingest module
* loader.
*/
List<IngestModuleFactory> moduleFactories = IngestModuleFactoryLoader.getIngestModuleFactories();
List<IngestModuleFactory> moduleFactories = new ArrayList<>();
List<IngestModuleFactory> allModuleFactories = IngestModuleFactoryLoader.getIngestModuleFactories();
HashSet<String> loadedModuleNames = new HashSet<>();
// Add modules that are going to be used for this ingest depending on type.
for (IngestModuleFactory moduleFactory : allModuleFactories) {
if (this.ingestType.equals(IngestType.ALL_MODULES)) {
moduleFactories.add(moduleFactory);
} else if (this.ingestType.equals(IngestType.DATA_SOURCE_ONLY) && moduleFactory.isDataSourceIngestModuleFactory()) {
moduleFactories.add(moduleFactory);
} else if (this.ingestType.equals(IngestType.FILES_ONLY) && moduleFactory.isFileIngestModuleFactory()) {
moduleFactories.add(moduleFactory);
}
}
for (IngestModuleFactory moduleFactory : moduleFactories) {
loadedModuleNames.add(moduleFactory.getModuleDisplayName());
}

View File

@ -34,7 +34,9 @@ import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import org.openide.util.NbBundle;
import org.sleuthkit.autopsy.ingest.IngestJobSettings.IngestType;
import org.sleuthkit.datamodel.Content;
import org.sleuthkit.datamodel.Directory;
/**
* Dialog box that allows a user to configure and run an ingest job on one or
@ -43,6 +45,7 @@ import org.sleuthkit.datamodel.Content;
public final class RunIngestModulesDialog extends JDialog {
private static final String TITLE = NbBundle.getMessage(RunIngestModulesDialog.class, "IngestDialog.title.text");
private final IngestType ingestType;
private static Dimension DIMENSIONS = new Dimension(500, 300);
private final List<Content> dataSources = new ArrayList<>();
private IngestJobSettingsPanel ingestJobSettingsPanel;
@ -59,6 +62,7 @@ public final class RunIngestModulesDialog extends JDialog {
public RunIngestModulesDialog(JFrame frame, String title, boolean modal, List<Content> dataSources) {
super(frame, title, modal);
this.dataSources.addAll(dataSources);
this.ingestType = IngestType.ALL_MODULES;
}
/**
@ -70,6 +74,11 @@ public final class RunIngestModulesDialog extends JDialog {
public RunIngestModulesDialog(List<Content> dataSources) {
this(new JFrame(TITLE), TITLE, true, dataSources);
}
public RunIngestModulesDialog(Directory dir) {
this.dataSources.add(dir);
this.ingestType = IngestType.FILES_ONLY;
}
/**
* Construct a dialog box that allows a user to configure and run an ingest
@ -84,6 +93,7 @@ public final class RunIngestModulesDialog extends JDialog {
@Deprecated
public RunIngestModulesDialog(JFrame frame, String title, boolean modal) {
super(frame, title, modal);
this.ingestType = IngestType.ALL_MODULES;
}
/**
@ -129,7 +139,7 @@ public final class RunIngestModulesDialog extends JDialog {
* Get the default or saved ingest job settings for this context and use
* them to create and add an ingest job settings panel.
*/
IngestJobSettings ingestJobSettings = new IngestJobSettings(RunIngestModulesDialog.class.getCanonicalName());
IngestJobSettings ingestJobSettings = new IngestJobSettings(RunIngestModulesDialog.class.getCanonicalName(), this.ingestType);
RunIngestModulesDialog.showWarnings(ingestJobSettings);
this.ingestJobSettingsPanel = new IngestJobSettingsPanel(ingestJobSettings);
add(this.ingestJobSettingsPanel, BorderLayout.PAGE_START);