diff --git a/Core/src/org/sleuthkit/autopsy/ingest/DataSourceIngestJob.java b/Core/src/org/sleuthkit/autopsy/ingest/DataSourceIngestJob.java index 0800267139..27ddb8bbb8 100644 --- a/Core/src/org/sleuthkit/autopsy/ingest/DataSourceIngestJob.java +++ b/Core/src/org/sleuthkit/autopsy/ingest/DataSourceIngestJob.java @@ -31,7 +31,6 @@ import java.util.logging.Level; import javax.swing.JOptionPane; import org.netbeans.api.progress.ProgressHandle; import org.openide.util.Cancellable; -import org.openide.util.Exceptions; import org.openide.util.NbBundle; import org.sleuthkit.autopsy.casemodule.Case; import org.sleuthkit.autopsy.coreutils.Logger; @@ -258,15 +257,18 @@ final class DataSourceIngestJob { try { for (IngestModuleTemplate module : firstStageDataSourceModuleTemplates) { IngestModuleType type = module.isDataSourceIngestModuleTemplate() ? IngestModuleType.DATA_SOURCE_LEVEL : IngestModuleType.FILE_LEVEL; - ingestModules.add(skCase.addIngestModule(module.getModuleName(), currentFileIngestTask, type, module.getModuleFactory().getModuleVersionNumber())); + String uniqueName = FactoryClassNameNormalizer.normalize(module.getModuleFactory().getClass().getCanonicalName()) + "-" + module.getModuleFactory().getModuleDisplayName() + "-" + type.getTypeName() + "-" + module.getModuleFactory().getModuleVersionNumber(); + ingestModules.add(skCase.addIngestModule(module.getModuleName(), uniqueName, type, module.getModuleFactory().getModuleVersionNumber())); } for (IngestModuleTemplate module : fileIngestModuleTemplates) { IngestModuleType type = module.isDataSourceIngestModuleTemplate() ? IngestModuleType.DATA_SOURCE_LEVEL : IngestModuleType.FILE_LEVEL; - ingestModules.add(skCase.addIngestModule(module.getModuleName(), currentFileIngestTask, type, module.getModuleFactory().getModuleVersionNumber())); + String uniqueName = FactoryClassNameNormalizer.normalize(module.getModuleFactory().getClass().getCanonicalName()) + "-" + module.getModuleFactory().getModuleDisplayName() + "-" + type.getTypeName() + "-" + module.getModuleFactory().getModuleVersionNumber(); + ingestModules.add(skCase.addIngestModule(module.getModuleName(), uniqueName, type, module.getModuleFactory().getModuleVersionNumber())); } for (IngestModuleTemplate module : secondStageDataSourceModuleTemplates) { IngestModuleType type = module.isDataSourceIngestModuleTemplate() ? IngestModuleType.DATA_SOURCE_LEVEL : IngestModuleType.FILE_LEVEL; - ingestModules.add(skCase.addIngestModule(module.getModuleName(), currentFileIngestTask, type, module.getModuleFactory().getModuleVersionNumber())); + String uniqueName = FactoryClassNameNormalizer.normalize(module.getModuleFactory().getClass().getCanonicalName()) + "-" + module.getModuleFactory().getModuleDisplayName() + "-" + type.getTypeName() + "-" + module.getModuleFactory().getModuleVersionNumber(); + ingestModules.add(skCase.addIngestModule(module.getModuleName(), uniqueName, type, module.getModuleFactory().getModuleVersionNumber())); } } catch (TskCoreException ex) { logger.log(Level.SEVERE, "Failed to add ingest modules to database.", ex); @@ -396,7 +398,7 @@ final class DataSourceIngestJob { try { this.ingestJob = Case.getCurrentCase().getSleuthkitCase().addIngestJob(dataSource, NetworkUtils.getLocalHostName(), ingestModules, this.createTime); } catch (TskCoreException ex) { - logger.log(Level.SEVERE, "Failed to add ingest job to database.", ex); + logger.log(Level.SEVERE, "Failed to add ingest job to database.", ex); } } return errors; @@ -674,14 +676,14 @@ final class DataSourceIngestJob { } } } - try { - this.ingestJob.setEndDate(new Date().toInstant().toEpochMilli()); - } catch (TskCoreException ex) { - logger.log(Level.SEVERE, "Failed to set end date for ingest job in database.", ex); - } catch (TskDataException ex) { - Exceptions.printStackTrace(ex); + if (!this.cancelled) { + try { + this.ingestJob.setEndDate(new Date().toInstant().toEpochMilli()); + } catch (TskCoreException | TskDataException ex) { + logger.log(Level.SEVERE, "Failed to set end date for ingest job in database.", ex); + } + this.parentJob.dataSourceJobFinished(this); } - this.parentJob.dataSourceJobFinished(this); } /** diff --git a/Core/src/org/sleuthkit/autopsy/ingest/FactoryClassNameNormalizer.java b/Core/src/org/sleuthkit/autopsy/ingest/FactoryClassNameNormalizer.java new file mode 100755 index 0000000000..be12540921 --- /dev/null +++ b/Core/src/org/sleuthkit/autopsy/ingest/FactoryClassNameNormalizer.java @@ -0,0 +1,42 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package org.sleuthkit.autopsy.ingest; + +import org.sleuthkit.autopsy.coreutils.Logger; + +/** + * Used to strip python ids on factory class names. + */ +class FactoryClassNameNormalizer { + + private static final CharSequence pythonModuleSettingsPrefixCS = "org.python.proxies.".subSequence(0, "org.python.proxies.".length() - 1); //NON-NLS + private static final Logger logger = Logger.getLogger(FactoryClassNameNormalizer.class.getName()); + + static String normalize(String canonicalClassName) { + if (isPythonModuleSettingsFile(canonicalClassName)) { + // compiled python modules have variable instance number as a part of their file name. + // This block of code gets rid of that variable instance number and helps maitains constant module name over multiple runs. + String moduleClassName = canonicalClassName.replaceAll("[$][\\d]", "\\"); //NON-NLS NON-NLS + return moduleClassName; + } + return canonicalClassName; + } + + /** + * Determines if the moduleSettingsFilePath is that of a serialized jython + * instance. Serialized Jython instances (settings saved on the disk) + * contain "org.python.proxies." in their fileName based on the current + * implementation. + * + * @param moduleSettingsFilePath path to the module settings file. + * + * @return True or false + */ + private static boolean isPythonModuleSettingsFile(String moduleSettingsFilePath) { + return moduleSettingsFilePath.contains(pythonModuleSettingsPrefixCS); + } + +} diff --git a/Core/src/org/sleuthkit/autopsy/ingest/IngestJobSettings.java b/Core/src/org/sleuthkit/autopsy/ingest/IngestJobSettings.java index 827bbc016d..58644dc05a 100644 --- a/Core/src/org/sleuthkit/autopsy/ingest/IngestJobSettings.java +++ b/Core/src/org/sleuthkit/autopsy/ingest/IngestJobSettings.java @@ -33,10 +33,10 @@ import java.util.logging.Level; import org.openide.util.NbBundle; import org.openide.util.io.NbObjectInputStream; import org.openide.util.io.NbObjectOutputStream; +import org.python.util.PythonObjectInputStream; +import org.sleuthkit.autopsy.coreutils.Logger; import org.sleuthkit.autopsy.coreutils.ModuleSettings; import org.sleuthkit.autopsy.coreutils.PlatformUtil; -import org.sleuthkit.autopsy.coreutils.Logger; -import org.python.util.PythonObjectInputStream; /** * Encapsulates the ingest job settings for a particular execution context. @@ -467,17 +467,9 @@ public class IngestJobSettings { * @param settings The ingest job settings for the ingest module */ private void saveModuleSettings(IngestModuleFactory factory, IngestModuleIngestJobSettings settings) { - try { - String moduleSettingsFilePath = getModuleSettingsFilePath(factory); - // compiled python modules have substring org.python.proxies. It can be used to identify them. - if (isPythonModuleSettingsFile(moduleSettingsFilePath)) { - // compiled python modules have variable instance number as a part of their file name. - // This block of code gets rid of that variable instance number and helps maitains constant module name over multiple runs. - moduleSettingsFilePath = moduleSettingsFilePath.replaceAll("[$][\\d]+.settings$", "\\$.settings"); //NON-NLS NON-NLS - } - try (NbObjectOutputStream out = new NbObjectOutputStream(new FileOutputStream(moduleSettingsFilePath))) { - out.writeObject(settings); - } + String moduleSettingsFilePath = FactoryClassNameNormalizer.normalize(factory.getClass().getCanonicalName()) + MODULE_SETTINGS_FILE_EXT; + try (NbObjectOutputStream out = new NbObjectOutputStream(new FileOutputStream(moduleSettingsFilePath))) { + out.writeObject(settings); } catch (IOException ex) { String warning = NbBundle.getMessage(IngestJobSettings.class, "IngestJobSettings.moduleSettingsSave.warning", factory.getModuleDisplayName(), this.executionContext); //NON-NLS logger.log(Level.SEVERE, warning, ex);