mirror of
https://github.com/elisspace/autopsy.git
synced 2026-09-06 02:24:30 +00:00
new datasource module runs now
This commit is contained in:
@@ -23,11 +23,14 @@ package org.sleuthkit.autopsy.modules.externalresults;
|
||||
import java.io.File;
|
||||
import org.sleuthkit.autopsy.casemodule.Case;
|
||||
import org.sleuthkit.autopsy.coreutils.Logger;
|
||||
import org.sleuthkit.autopsy.examples.SampleIngestModuleFactory;
|
||||
import org.sleuthkit.autopsy.ingest.DataSourceIngestModule;
|
||||
import org.sleuthkit.autopsy.ingest.DataSourceIngestModuleProgress;
|
||||
import org.sleuthkit.autopsy.ingest.IngestJobContext;
|
||||
import org.sleuthkit.autopsy.ingest.IngestMessage;
|
||||
import org.sleuthkit.autopsy.ingest.IngestModuleAdapter;
|
||||
import org.sleuthkit.autopsy.ingest.IngestModuleReferenceCounter;
|
||||
import org.sleuthkit.autopsy.ingest.IngestServices;
|
||||
import org.sleuthkit.datamodel.Content;
|
||||
|
||||
/**
|
||||
@@ -36,38 +39,54 @@ import org.sleuthkit.datamodel.Content;
|
||||
public class ExternalResultsIngestModule extends IngestModuleAdapter implements DataSourceIngestModule {
|
||||
private static final Logger logger = Logger.getLogger(ExternalResultsIngestModule.class.getName());
|
||||
private static final IngestModuleReferenceCounter refCounter = new IngestModuleReferenceCounter();
|
||||
private static final String MODULE_DIR = "ExternalResults";
|
||||
private static final String IMPORT_DIR = "import";
|
||||
private long jobId;
|
||||
private String reportPath;
|
||||
private String importPath;
|
||||
DataSourceIngestModuleProgress progressBar;
|
||||
|
||||
@Override
|
||||
public void startUp(IngestJobContext context) throws IngestModuleException {
|
||||
jobId = context.getJobId();
|
||||
|
||||
///@todo get reportPath config from user
|
||||
reportPath = Case.getCurrentCase().getModulesOutputDirAbsPath() + File.separator + "ExternalResults";
|
||||
// By default, we create the import path and provide it to the third party executable as an argument
|
||||
importPath = Case.getCurrentCase().getModulesOutputDirAbsPath() + File.separator + MODULE_DIR + File.separator + IMPORT_DIR;
|
||||
|
||||
refCounter.incrementAndGet(jobId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ProcessResult process(Content dataSource, DataSourceIngestModuleProgress statusHelper) {
|
||||
progressBar = statusHelper;
|
||||
progressBar.switchToDeterminate(2);
|
||||
|
||||
if (refCounter.incrementAndGet(jobId) == 1) {
|
||||
if (refCounter.get(jobId) == 1) {
|
||||
runAndImportResults();
|
||||
}
|
||||
}
|
||||
|
||||
return ProcessResult.OK;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void shutDown(boolean ingestJobCancelled) {
|
||||
IngestMessage message = IngestMessage.createMessage(
|
||||
IngestMessage.MessageType.DATA,
|
||||
ExternalResultsModuleFactory.getModuleName(),
|
||||
"Finished.");
|
||||
IngestServices.getInstance().postMessage(message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Launch the third-party process and import the results
|
||||
*/
|
||||
private void runAndImportResults() {
|
||||
///@todo run exe
|
||||
///@todo run exe, passing the data source path and the import (results) path
|
||||
progressBar.progress(1);
|
||||
|
||||
// execution is done, look for results to import
|
||||
ExternalResultsXML parser = new ExternalResultsXML(reportPath);
|
||||
ExternalResultsXML parser = new ExternalResultsXML(importPath);
|
||||
ExternalResultsUtility.importResults(parser);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ProcessResult process(Content dataSource, DataSourceIngestModuleProgress statusHelper) {
|
||||
|
||||
//do nothing
|
||||
return ProcessResult.OK;
|
||||
progressBar.progress(1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -26,7 +26,6 @@ import org.sleuthkit.autopsy.coreutils.Version;
|
||||
import org.sleuthkit.autopsy.ingest.IngestModuleFactory;
|
||||
import org.sleuthkit.autopsy.ingest.IngestModuleFactoryAdapter;
|
||||
import org.sleuthkit.autopsy.ingest.IngestModuleIngestJobSettings;
|
||||
import org.sleuthkit.autopsy.modules.exif.ExifParserFileIngestModule;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -40,14 +39,14 @@ public class ExternalResultsModuleFactory extends IngestModuleFactoryAdapter {
|
||||
}
|
||||
|
||||
static String getModuleName() {
|
||||
return NbBundle.getMessage(ExifParserFileIngestModule.class,
|
||||
return NbBundle.getMessage(ExternalResultsIngestModule.class,
|
||||
"ExternalResultsIngestModule.moduleName.text");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getModuleDescription() {
|
||||
return NbBundle.getMessage(ExternalResultsIngestModule.class,
|
||||
"ExternalResultsIngestModule.getDesc.text");
|
||||
"ExternalResultsIngestModule.moduleDesc.text");
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -56,7 +55,7 @@ public class ExternalResultsModuleFactory extends IngestModuleFactoryAdapter {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFileIngestModuleFactory() {
|
||||
public boolean isDataSourceIngestModuleFactory() {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user