AutomatedIngestDataSourceProcessor interface methods throw exception

This commit is contained in:
Eugene Livis 2016-08-19 11:37:58 -04:00
parent 0fbde22ee0
commit e0a75cf9fb
8 changed files with 69 additions and 35 deletions

View File

@ -160,6 +160,7 @@ GeneralFilter.encaseImageDesc.text=Encase Images (*.e01)
GeneralFilter.virtualMachineImageDesc.text=Virtual Machines (*.vmdk, *.vhd)
ImageDSProcessor.dsType.text=Image or VM File
ImageDSProcessor.allDesc.text=All Supported Types
ImageDSProcessor.canProcess.exception.text=Exception inside canProcess() method
ImageFilePanel.moduleErr=Module Error
ImageFilePanel.moduleErr.msg=A module caused an error listening to ImageFilePanel updates. See log to determine which module. Some data could be incomplete.
LocalDiskDSProcessor.dsType.text=Local Disk

View File

@ -248,7 +248,7 @@ public class ImageDSProcessor implements AutomatedIngestDataSourceProcessor {
}
@Override
public int canProcess(Path dataSourcePath) {
public int canProcess(Path dataSourcePath) throws AutomatedIngestDataSourceProcessorException {
// check file extension for supported types
if (!isAcceptedByFiler(dataSourcePath.toFile(), filtersList)) {
@ -262,9 +262,8 @@ public class ImageDSProcessor implements AutomatedIngestDataSourceProcessor {
// image does not have a file system that TSK can process
return 0;
}
} catch (Exception ignore) {
// ELTODO do we want to have error message here?
return 0;
} catch (Exception ex) {
throw new AutomatedIngestDataSourceProcessorException(NbBundle.getMessage(ImageDSProcessor.class, "ImageDSProcessor.canProcess.exception.text"), ex);
}
// able to process the data source
@ -272,8 +271,7 @@ public class ImageDSProcessor implements AutomatedIngestDataSourceProcessor {
}
@Override
public void process(String deviceId, Path dataSourcePath, DataSourceProcessorProgressMonitor progressMonitor, DataSourceProcessorCallback callBack) {
public void process(String deviceId, Path dataSourcePath, DataSourceProcessorProgressMonitor progressMonitor, DataSourceProcessorCallback callBack) throws AutomatedIngestDataSourceProcessorException {
this.deviceId = deviceId;
this.imagePath = dataSourcePath.toString();
this.timeZone = Calendar.getInstance().getTimeZone().getID();

View File

@ -205,7 +205,7 @@ public class LocalFilesDSProcessor implements AutomatedIngestDataSourceProcessor
}
@Override
public int canProcess(Path dataSourcePath) {
public int canProcess(Path dataSourcePath) throws AutomatedIngestDataSourceProcessorException {
// Local files DSP can process any file by simply adding it as a logical file.
// It should return lowest possible non-zero confidence level and be treated
// as the "option of last resort" for auto ingest purposes
@ -213,7 +213,7 @@ public class LocalFilesDSProcessor implements AutomatedIngestDataSourceProcessor
}
@Override
public void process(String deviceId, Path dataSourcePath, DataSourceProcessorProgressMonitor progressMonitor, DataSourceProcessorCallback callBack) {
public void process(String deviceId, Path dataSourcePath, DataSourceProcessorProgressMonitor progressMonitor, DataSourceProcessorCallback callBack) throws AutomatedIngestDataSourceProcessorException {
this.localFilePaths = Arrays.asList(new String[]{dataSourcePath.toString()});
run(deviceId, AUTO_INGEST_VIRTUAL_DIR_NAME, this.localFilePaths, progressMonitor, callBack);
}

View File

@ -26,7 +26,7 @@ import java.nio.file.Path;
*
* @author elivis
*/
public interface AutomatedIngestDataSourceProcessor extends DataSourceProcessor{
public interface AutomatedIngestDataSourceProcessor extends DataSourceProcessor {
/**
* Indicates whether the DataSourceProcessor is capable of processing the
@ -38,8 +38,11 @@ public interface AutomatedIngestDataSourceProcessor extends DataSourceProcessor{
* or less means the data source is not supported by the
* DataSourceProcessor. Value of 100 indicates high certainty in
* being able to process the data source.
*
* @throws
* org.sleuthkit.autopsy.corecomponentinterfaces.AutomatedIngestDataSourceProcessor.AutomatedIngestDataSourceProcessorException
*/
int canProcess(Path dataSourcePath);
int canProcess(Path dataSourcePath) throws AutomatedIngestDataSourceProcessorException;
/**
*
@ -51,6 +54,25 @@ public interface AutomatedIngestDataSourceProcessor extends DataSourceProcessor{
* background task to report progress.
* @param callBack Callback that will be used by the background task
* to return results.
*
* @throws
* org.sleuthkit.autopsy.corecomponentinterfaces.AutomatedIngestDataSourceProcessor.AutomatedIngestDataSourceProcessorException
*/
void process(String deviceId, Path dataSourcePath, DataSourceProcessorProgressMonitor progressMonitor, DataSourceProcessorCallback callBack);
void process(String deviceId, Path dataSourcePath, DataSourceProcessorProgressMonitor progressMonitor, DataSourceProcessorCallback callBack) throws AutomatedIngestDataSourceProcessorException;
/**
* A custom exception for the use of AutomatedIngestDataSourceProcessor.
*/
public class AutomatedIngestDataSourceProcessorException extends Exception {
private static final long serialVersionUID = 1L;
public AutomatedIngestDataSourceProcessorException(String message) {
super(message);
}
public AutomatedIngestDataSourceProcessorException(String message, Throwable cause) {
super(message, cause);
}
}
}

View File

@ -2103,7 +2103,12 @@ public final class AutoIngestManager extends Observable implements PropertyChang
AutomatedIngestDataSourceProcessor selectedProcessor = null;
int selectedProcessorConfidence = 0;
for (AutomatedIngestDataSourceProcessor processor : processorCandidates) {
int confidence = processor.canProcess(dataSource.getPath());
int confidence = 0;
try {
confidence = processor.canProcess(dataSource.getPath());
} catch (AutomatedIngestDataSourceProcessor.AutomatedIngestDataSourceProcessorException ex) {
// ELTODO : log and auto-pause
}
if (confidence > selectedProcessorConfidence) {
selectedProcessor = processor;
selectedProcessorConfidence = confidence;
@ -2119,8 +2124,12 @@ public final class AutoIngestManager extends Observable implements PropertyChang
synchronized (ingestLock) {
LOGGER.log(Level.INFO, "Identified data source type for {0} as {1}", new Object[]{manifestPath, selectedProcessor.getDataSourceType()});
// ELTODO add sys log and possibly case log entries here
selectedProcessor.process(dataSource.getDeviceId(), dataSource.getPath(), progressMonitor, callBack);
try {
// ELTODO add sys log and possibly case log entries here
selectedProcessor.process(dataSource.getDeviceId(), dataSource.getPath(), progressMonitor, callBack);
} catch (AutomatedIngestDataSourceProcessor.AutomatedIngestDataSourceProcessorException ex) {
// ELTODO : log and auto-pause
}
ingestLock.wait();
}
} finally {

View File

@ -25,3 +25,4 @@ CellebriteLogicalReportPanel.jLabel1.text=Input type:
CellebriteLogicalReportPanel.jHandsetRadioButton.text=Handset
CellebriteLogicalReportPanel.browseButton.text=Browse
CellebriteLogicalReportPanel.pathTextField.text=
CellebritePhysicalReportProcessor.canProcess.exception.text=Exception inside canProcess() method

View File

@ -250,7 +250,7 @@ public class CellebriteLogicalReportProcessor implements AutomatedIngestDataSour
}
@Override
public int canProcess(Path dataSourcePath) {
public int canProcess(Path dataSourcePath) throws AutomatedIngestDataSourceProcessorException {
ReportType type = parseCellebriteLogicalReportType(dataSourcePath);
switch (type) {
case CELLEBRITE_LOGICAL_HANDSET:
@ -263,7 +263,7 @@ public class CellebriteLogicalReportProcessor implements AutomatedIngestDataSour
}
@Override
public void process(String deviceId, Path dataSourcePath, DataSourceProcessorProgressMonitor progressMonitor, DataSourceProcessorCallback callBack) {
public void process(String deviceId, Path dataSourcePath, DataSourceProcessorProgressMonitor progressMonitor, DataSourceProcessorCallback callBack) throws AutomatedIngestDataSourceProcessorException {
ReportType type = parseCellebriteLogicalReportType(dataSourcePath);
boolean isHandsetFile = false;
switch (type) {

View File

@ -37,7 +37,7 @@ import java.util.zip.ZipFile;
import javax.swing.JPanel;
import javax.swing.filechooser.FileFilter;
import org.apache.commons.io.FilenameUtils;
import org.openide.util.Exceptions;
import org.openide.util.NbBundle;
import org.openide.util.lookup.ServiceProvider;
import org.openide.util.lookup.ServiceProviders;
import org.sleuthkit.autopsy.casemodule.Case;
@ -257,18 +257,6 @@ public class CellebritePhysicalReportProcessor implements AutomatedIngestDataSou
private static boolean isValidDataSource(Path dataSourcePath) {
String fileName = dataSourcePath.getFileName().toString();
// check whether it's a zip archive file
if (isAcceptedByFiler(new File(fileName), archiveFilters)) {
try {
Case currentCase = Case.getCurrentCase();
Path extractedDataSource = extractDataSource(Paths.get(currentCase.getModuleDirectory()), dataSourcePath);
} catch (Exception ex) {
// ELTODO add log here?
return false;
}
}
// is it a ".bin" image
if (!isAcceptedByFiler(new File(fileName), cellebriteImageFiltersList)) {
return false;
@ -300,10 +288,25 @@ public class CellebritePhysicalReportProcessor implements AutomatedIngestDataSou
return false;
}
private static boolean isArchive(Path dataSourcePath) throws AutomatedIngestDataSourceProcessorException {
String fileName = dataSourcePath.getFileName().toString();
// check whether it's a zip archive file
if (isAcceptedByFiler(new File(fileName), archiveFilters)) {
try {
Case currentCase = Case.getCurrentCase();
Path extractedDataSource = extractDataSource(Paths.get(currentCase.getModuleDirectory()), dataSourcePath);
} catch (Exception ex) {
throw new AutomatedIngestDataSourceProcessorException(NbBundle.getMessage(CellebritePhysicalReportProcessor.class, "CellebritePhysicalReportProcessor.canProcess.exception.text"), ex);
}
}
return true;
}
@Override
public int canProcess(Path dataSourcePath) {
// check whether this is a ".bin" file
if (isValidDataSource(dataSourcePath)) {
public int canProcess(Path dataSourcePath) throws AutomatedIngestDataSourceProcessorException {
// check whether this is an archive or a ".bin" file
if (isArchive(dataSourcePath) || isValidDataSource(dataSourcePath)) {
// return "high confidence" value
return 90;
}
@ -311,7 +314,7 @@ public class CellebritePhysicalReportProcessor implements AutomatedIngestDataSou
}
@Override
public void process(String deviceId, Path dataSourcePath, DataSourceProcessorProgressMonitor progressMonitor, DataSourceProcessorCallback callBack) {
public void process(String deviceId, Path dataSourcePath, DataSourceProcessorProgressMonitor progressMonitor, DataSourceProcessorCallback callBack) throws AutomatedIngestDataSourceProcessorException {
List<String> dataSourcePathList = Arrays.asList(new String[]{dataSourcePath.toString()});
// in this particular case we don't want to call run() method as it will try to identify and process all ".bin" files in data source folder
addImagesTask = new AddCellebritePhysicalReportTask(deviceId, dataSourcePathList, "", progressMonitor, callBack);