mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-15 09:17:42 +00:00
Correctly support ingest of a subset of files from data source
This commit is contained in:
parent
7f69132238
commit
ae3bfc83e8
@ -20,17 +20,14 @@ package org.sleuthkit.autopsy.datamodel;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import javax.swing.Action;
|
||||
import org.openide.util.NbBundle;
|
||||
import org.openide.util.Utilities;
|
||||
import org.sleuthkit.autopsy.actions.AddContentTagAction;
|
||||
import org.sleuthkit.autopsy.actions.DeleteFileContentTagAction;
|
||||
import org.sleuthkit.autopsy.coreutils.ContextMenuExtensionPoint;
|
||||
import org.sleuthkit.autopsy.coreutils.Logger;
|
||||
import org.sleuthkit.autopsy.directorytree.ExtractAction;
|
||||
import org.sleuthkit.autopsy.directorytree.NewWindowViewAction;
|
||||
import org.sleuthkit.autopsy.directorytree.ViewContextAction;
|
||||
@ -38,7 +35,6 @@ import org.sleuthkit.autopsy.ingest.runIngestModuleWizard.RunIngestModulesAction
|
||||
import org.sleuthkit.autopsy.timeline.actions.ViewFileInTimelineAction;
|
||||
import org.sleuthkit.datamodel.AbstractFile;
|
||||
import org.sleuthkit.datamodel.Directory;
|
||||
import org.sleuthkit.datamodel.TskCoreException;
|
||||
import org.sleuthkit.datamodel.TskData.TSK_FS_NAME_FLAG_ENUM;
|
||||
|
||||
/**
|
||||
@ -47,8 +43,6 @@ import org.sleuthkit.datamodel.TskData.TSK_FS_NAME_FLAG_ENUM;
|
||||
*/
|
||||
public class DirectoryNode extends AbstractFsContentNode<AbstractFile> {
|
||||
|
||||
private static final Logger LOGGER = Logger.getLogger(DirectoryNode.class.getName());
|
||||
|
||||
public static final String DOTDOTDIR = NbBundle.getMessage(DirectoryNode.class, "DirectoryNode.parFolder.text");
|
||||
public static final String DOTDIR = NbBundle.getMessage(DirectoryNode.class, "DirectoryNode.curFolder.text");
|
||||
|
||||
@ -96,11 +90,7 @@ public class DirectoryNode extends AbstractFsContentNode<AbstractFile> {
|
||||
actionsList.add(null); // creates a menu separator
|
||||
actionsList.add(ExtractAction.getInstance());
|
||||
actionsList.add(null); // creates a menu separator
|
||||
try {
|
||||
actionsList.add(new RunIngestModulesAction(content.getDataSource(), Collections.<AbstractFile>singletonList(content)));
|
||||
} catch (TskCoreException ex) {
|
||||
LOGGER.log(Level.SEVERE, String.format("Failed to get data source for directory %s (objId=%d), RunIngestModulesAction omitted from context menu", content.getName(), content.getId()), ex);
|
||||
}
|
||||
actionsList.add(new RunIngestModulesAction(content));
|
||||
actionsList.add(null); // creates a menu separator
|
||||
actionsList.add(AddContentTagAction.getInstance());
|
||||
|
||||
|
@ -19,28 +19,20 @@
|
||||
package org.sleuthkit.autopsy.datamodel;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import javax.swing.Action;
|
||||
import org.openide.util.NbBundle;
|
||||
import org.sleuthkit.autopsy.coreutils.ContextMenuExtensionPoint;
|
||||
import org.sleuthkit.autopsy.coreutils.Logger;
|
||||
import org.sleuthkit.autopsy.directorytree.ExtractAction;
|
||||
import org.sleuthkit.autopsy.directorytree.FileSearchAction;
|
||||
import org.sleuthkit.autopsy.directorytree.NewWindowViewAction;
|
||||
import org.sleuthkit.autopsy.ingest.runIngestModuleWizard.RunIngestModulesAction;
|
||||
import org.sleuthkit.datamodel.AbstractFile;
|
||||
import org.sleuthkit.datamodel.SpecialDirectory;
|
||||
import org.sleuthkit.datamodel.Content;
|
||||
import org.sleuthkit.datamodel.TskCoreException;
|
||||
|
||||
/**
|
||||
* Parent class for special directory types (Local and Virtual)
|
||||
*/
|
||||
public abstract class SpecialDirectoryNode extends AbstractAbstractFileNode<SpecialDirectory> {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(SpecialDirectoryNode.class.getName());
|
||||
|
||||
public SpecialDirectoryNode(SpecialDirectory sd) {
|
||||
super(sd);
|
||||
@ -68,11 +60,7 @@ public abstract class SpecialDirectoryNode extends AbstractAbstractFileNode<Spec
|
||||
actions.add(ExtractAction.getInstance());
|
||||
actions.add(null); // creates a menu separator
|
||||
actions.add(new FileSearchAction(Bundle.ImageNode_getActions_openFileSearchByAttr_text()));
|
||||
try {
|
||||
actions.add(new RunIngestModulesAction(content.getDataSource(), Collections.<AbstractFile>singletonList(content)));
|
||||
} catch (TskCoreException ex) {
|
||||
logger.log(Level.SEVERE, String.format("Failed to get data source for special directory %s (objId=%d), RunIngestModulesAction omitted from context menu", content.getName(), content.getId()), ex);
|
||||
}
|
||||
actions.add(new RunIngestModulesAction(content));
|
||||
actions.addAll(ContextMenuExtensionPoint.getActions());
|
||||
return actions.toArray(new Action[0]);
|
||||
}
|
||||
|
@ -24,6 +24,7 @@ import java.text.MessageFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import javax.swing.AbstractAction;
|
||||
import javax.swing.Action;
|
||||
import javax.swing.JOptionPane;
|
||||
@ -32,19 +33,24 @@ import org.openide.DialogDisplayer;
|
||||
import org.openide.WizardDescriptor;
|
||||
import org.openide.util.NbBundle.Messages;
|
||||
import org.openide.windows.WindowManager;
|
||||
import org.sleuthkit.autopsy.coreutils.Logger;
|
||||
import org.sleuthkit.autopsy.coreutils.MessageNotifyUtil;
|
||||
import org.sleuthkit.autopsy.datamodel.SpecialDirectoryNode;
|
||||
import org.sleuthkit.autopsy.ingest.IngestJobSettings;
|
||||
import org.sleuthkit.autopsy.ingest.IngestManager;
|
||||
import org.sleuthkit.datamodel.AbstractFile;
|
||||
import org.sleuthkit.datamodel.Content;
|
||||
import org.sleuthkit.datamodel.TskCoreException;
|
||||
|
||||
/**
|
||||
* An action that invokes the Run Ingest Modules wizard for one or more data
|
||||
* sources or a subset of the files in a single data source.
|
||||
* sources or for the children of a file.
|
||||
*/
|
||||
public final class RunIngestModulesAction extends AbstractAction {
|
||||
|
||||
@Messages("RunIngestModulesAction.name=Run Ingest Modules")
|
||||
private static final long serialVersionUID = 1L;
|
||||
private static final Logger logger = Logger.getLogger(SpecialDirectoryNode.class.getName());
|
||||
|
||||
/*
|
||||
* Note that the execution context is the name of the dialog that used to be
|
||||
@ -53,7 +59,7 @@ public final class RunIngestModulesAction extends AbstractAction {
|
||||
private static final String EXECUTION_CONTEXT = "org.sleuthkit.autopsy.ingest.RunIngestModulesDialog";
|
||||
private final List<Content> dataSources = new ArrayList<>();
|
||||
private final IngestJobSettings.IngestType ingestType;
|
||||
private final List<AbstractFile> files;
|
||||
private final AbstractFile parentFile;
|
||||
|
||||
/**
|
||||
* Display any warnings that the ingestJobSettings have.
|
||||
@ -81,21 +87,25 @@ public final class RunIngestModulesAction extends AbstractAction {
|
||||
this.putValue(Action.NAME, Bundle.RunIngestModulesAction_name());
|
||||
this.dataSources.addAll(dataSources);
|
||||
this.ingestType = IngestJobSettings.IngestType.ALL_MODULES;
|
||||
this.files = Collections.emptyList();
|
||||
this.parentFile = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs an action that invokes the Run Ingest Modules wizard for a
|
||||
* subset of the files in a single data source.
|
||||
* Constructs an action that invokes the Run Ingest Modules wizard for the
|
||||
* children of a file.
|
||||
*
|
||||
* @param dataSource The data source.
|
||||
* @param files The files.
|
||||
* @param file The file.
|
||||
*/
|
||||
public RunIngestModulesAction(Content dataSource, List<AbstractFile> files) {
|
||||
public RunIngestModulesAction(AbstractFile parentFile) {
|
||||
this.putValue(Action.NAME, Bundle.RunIngestModulesAction_name());
|
||||
this.dataSources.add(dataSource);
|
||||
this.parentFile = parentFile;
|
||||
this.ingestType = IngestJobSettings.IngestType.FILES_ONLY;
|
||||
this.files = new ArrayList<>(files);
|
||||
try {
|
||||
this.setEnabled(parentFile.hasChildren());
|
||||
} catch (TskCoreException ex) {
|
||||
logger.log(Level.SEVERE, String.format("Failed to get children count for parent file %s (objId=%d), RunIngestModulesAction disabled", parentFile.getName(), parentFile.getId()), ex);
|
||||
MessageNotifyUtil.Message.error(Bundle.RunIngestModulesAction_actionPerformed_errorMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -103,6 +113,9 @@ public final class RunIngestModulesAction extends AbstractAction {
|
||||
*
|
||||
* @param e the action event
|
||||
*/
|
||||
@Messages({
|
||||
"RunIngestModulesAction.actionPerformed.errorMessage=Error querying the case database for the selected item."
|
||||
})
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
/**
|
||||
@ -122,10 +135,25 @@ public final class RunIngestModulesAction extends AbstractAction {
|
||||
if (DialogDisplayer.getDefault().notify(wiz) == WizardDescriptor.FINISH_OPTION) {
|
||||
IngestJobSettings ingestJobSettings = wizard.getIngestJobSettings();
|
||||
showWarnings(ingestJobSettings);
|
||||
if (this.files.isEmpty()) {
|
||||
if (this.parentFile == null) {
|
||||
IngestManager.getInstance().queueIngestJob(this.dataSources, ingestJobSettings);
|
||||
} else {
|
||||
IngestManager.getInstance().queueIngestJob(this.dataSources.get(0), this.files, ingestJobSettings);
|
||||
try {
|
||||
Content dataSource = parentFile.getDataSource();
|
||||
List<Content> children = parentFile.getChildren();
|
||||
List<AbstractFile> files = new ArrayList<>();
|
||||
for (Content child : children) {
|
||||
if (child instanceof AbstractFile && child.getSize() > 0) {
|
||||
files.add((AbstractFile) child);
|
||||
}
|
||||
}
|
||||
if (files.isEmpty() == false) {
|
||||
IngestManager.getInstance().queueIngestJob(dataSource, files, ingestJobSettings);
|
||||
}
|
||||
} catch (TskCoreException ex) {
|
||||
logger.log(Level.SEVERE, String.format("Failed to get data source or children for parent file %s (objId=%d), action failed", parentFile.getName(), parentFile.getId()), ex);
|
||||
MessageNotifyUtil.Message.error(Bundle.RunIngestModulesAction_actionPerformed_errorMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user