ImageDSProcessor implements AutomatedIngestDataSourceProcessor interface

This commit is contained in:
Eugene Livis 2016-08-18 16:24:39 -04:00
parent 5bd74189b3
commit 8d9311a345
3 changed files with 55 additions and 5 deletions

View File

@ -18,6 +18,9 @@
*/ */
package org.sleuthkit.autopsy.casemodule; package org.sleuthkit.autopsy.casemodule;
import java.io.File;
import java.nio.file.Path;
import java.nio.file.Paths;
import javax.swing.JPanel; import javax.swing.JPanel;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Calendar; import java.util.Calendar;
@ -26,9 +29,12 @@ import java.util.UUID;
import javax.swing.filechooser.FileFilter; import javax.swing.filechooser.FileFilter;
import org.openide.util.NbBundle; import org.openide.util.NbBundle;
import org.openide.util.lookup.ServiceProvider; import org.openide.util.lookup.ServiceProvider;
import org.openide.util.lookup.ServiceProviders;
import org.sleuthkit.autopsy.corecomponentinterfaces.AutomatedIngestDataSourceProcessor;
import org.sleuthkit.autopsy.corecomponentinterfaces.DataSourceProcessorProgressMonitor; import org.sleuthkit.autopsy.corecomponentinterfaces.DataSourceProcessorProgressMonitor;
import org.sleuthkit.autopsy.corecomponentinterfaces.DataSourceProcessorCallback; import org.sleuthkit.autopsy.corecomponentinterfaces.DataSourceProcessorCallback;
import org.sleuthkit.autopsy.corecomponentinterfaces.DataSourceProcessor; import org.sleuthkit.autopsy.corecomponentinterfaces.DataSourceProcessor;
import org.sleuthkit.autopsy.coreutils.DataSourceUtils;
/** /**
* A image file data source processor that implements the DataSourceProcessor * A image file data source processor that implements the DataSourceProcessor
@ -36,8 +42,11 @@ import org.sleuthkit.autopsy.corecomponentinterfaces.DataSourceProcessor;
* wizard. It also provides a run method overload to allow it to be used * wizard. It also provides a run method overload to allow it to be used
* independently of the wizard. * independently of the wizard.
*/ */
@ServiceProvider(service = DataSourceProcessor.class) @ServiceProviders(value={
public class ImageDSProcessor implements DataSourceProcessor { @ServiceProvider(service=DataSourceProcessor.class),
@ServiceProvider(service=AutomatedIngestDataSourceProcessor.class)}
)
public class ImageDSProcessor implements DataSourceProcessor, AutomatedIngestDataSourceProcessor {
private final static String DATA_SOURCE_TYPE = NbBundle.getMessage(ImageDSProcessor.class, "ImageDSProcessor.dsType.text"); private final static String DATA_SOURCE_TYPE = NbBundle.getMessage(ImageDSProcessor.class, "ImageDSProcessor.dsType.text");
private static final List<String> allExt = new ArrayList<>(); private static final List<String> allExt = new ArrayList<>();
@ -229,4 +238,46 @@ public class ImageDSProcessor implements DataSourceProcessor {
setDataSourceOptionsCalled = true; setDataSourceOptionsCalled = true;
} }
private static boolean isAcceptedByFiler(File file, List<FileFilter> filters) {
for (FileFilter filter : filters) {
if (filter.accept(file)) {
return true;
}
}
return false;
}
@Override
public int canProcess(Path dataSourcePath) {
// check file extension for supported types
if (!isAcceptedByFiler(dataSourcePath.toFile(), filtersList)) {
return 0;
}
try {
// verify that the image has a file system that TSK can process
Case currentCase = Case.getCurrentCase();
if (!DataSourceUtils.imageHasFileSystem(Paths.get(currentCase.getTempDirectory()), dataSourcePath)) {
// image does not have a file system that TSK can process
return 0;
}
} catch (Exception ignore) {
return 0;
}
// able to process the data source
return 100;
}
@Override
public void process(String deviceId, Path dataSourcePath, DataSourceProcessorProgressMonitor progressMonitor, DataSourceProcessorCallback callBack) {
this.deviceId = deviceId;
this.imagePath = dataSourcePath.toString();
this.timeZone = Calendar.getInstance().getTimeZone().getID();
this.ignoreFatOrphanFiles = false;
setDataSourceOptionsCalled = true;
run(deviceId, dataSourcePath.toString(), timeZone, ignoreFatOrphanFiles, progressMonitor, callBack);
}
} }

View File

@ -2007,11 +2007,11 @@ public final class AutoIngestManager extends Observable implements PropertyChang
LOGGER.log(Level.INFO, "Identified data source type for {0} as {1} (VM)", new Object[]{manifestPath, DataSource.Type.DRIVE_IMAGE}); LOGGER.log(Level.INFO, "Identified data source type for {0} as {1} (VM)", new Object[]{manifestPath, DataSource.Type.DRIVE_IMAGE});
jobLogger.logDataSourceTypeId(DataSource.Type.DRIVE_IMAGE.toString()); jobLogger.logDataSourceTypeId(DataSource.Type.DRIVE_IMAGE.toString());
return new DataSource(deviceId, dataSourcePath, DataSource.Type.DRIVE_IMAGE); return new DataSource(deviceId, dataSourcePath, DataSource.Type.DRIVE_IMAGE);
} else if (imageHasFileSystem(caseForJob, dataSourcePath)) { } /*else if (imageHasFileSystem(caseForJob, dataSourcePath)) {
LOGGER.log(Level.INFO, "Identified data source type for {0} as {1}", new Object[]{manifestPath, DataSource.Type.DRIVE_IMAGE}); LOGGER.log(Level.INFO, "Identified data source type for {0} as {1}", new Object[]{manifestPath, DataSource.Type.DRIVE_IMAGE});
jobLogger.logDataSourceTypeId(DataSource.Type.DRIVE_IMAGE.toString()); jobLogger.logDataSourceTypeId(DataSource.Type.DRIVE_IMAGE.toString());
return new DataSource(deviceId, dataSourcePath, DataSource.Type.DRIVE_IMAGE); return new DataSource(deviceId, dataSourcePath, DataSource.Type.DRIVE_IMAGE);
} else { } */ else {
LOGGER.log(Level.INFO, "Identified data source type for {0} as {1}", new Object[]{manifestPath, DataSource.Type.PHONE_IMAGE}); LOGGER.log(Level.INFO, "Identified data source type for {0} as {1}", new Object[]{manifestPath, DataSource.Type.PHONE_IMAGE});
jobLogger.logDataSourceTypeId(DataSource.Type.PHONE_IMAGE.toString()); jobLogger.logDataSourceTypeId(DataSource.Type.PHONE_IMAGE.toString());
return new DataSource(deviceId, dataSourcePath, DataSource.Type.PHONE_IMAGE); return new DataSource(deviceId, dataSourcePath, DataSource.Type.PHONE_IMAGE);

View File

@ -20,7 +20,6 @@ package org.sleuthkit.autopsy.experimental.cellex.datasourceprocessors;
import java.io.File; import java.io.File;
import java.nio.file.Path; import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;