mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-16 17:57:43 +00:00
Made jobs end properly and created python stripping class.
This commit is contained in:
parent
dcd23b96b7
commit
e5fd92589f
@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
42
Core/src/org/sleuthkit/autopsy/ingest/FactoryClassNameNormalizer.java
Executable file
42
Core/src/org/sleuthkit/autopsy/ingest/FactoryClassNameNormalizer.java
Executable file
@ -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);
|
||||
}
|
||||
|
||||
}
|
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user