mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-12 16:06:15 +00:00
keep track of generated default module order, so it stays unique
add comments
This commit is contained in:
parent
7f7b8213b7
commit
6ef2834317
@ -81,6 +81,8 @@ public class IngestManager {
|
||||
private final IngestMonitor ingestMonitor = new IngestMonitor();
|
||||
//module loader
|
||||
private IngestModuleLoader moduleLoader = null;
|
||||
//property file name id for the module
|
||||
final static String MODULE_PROPERTIES = "ingest";
|
||||
|
||||
/**
|
||||
* Possible events about ingest modules Event listeners can get the event
|
||||
|
@ -78,6 +78,7 @@ import org.w3c.dom.Element;
|
||||
import org.w3c.dom.NodeList;
|
||||
import org.xml.sax.SAXException;
|
||||
import org.openide.filesystems.Repository;
|
||||
import org.sleuthkit.autopsy.coreutils.ModuleSettings;
|
||||
|
||||
/**
|
||||
* Class responsible for discovery and loading ingest modules specified in
|
||||
@ -114,13 +115,15 @@ public final class IngestModuleLoader {
|
||||
private final List<IngestModuleAbstractFile> filePipeline;
|
||||
private final List<IngestModuleImage> imagePipeline;
|
||||
private static final Logger logger = Logger.getLogger(IngestModuleLoader.class.getName());
|
||||
//for default module order if not specified/invalid
|
||||
private int currentLast = 0;
|
||||
private ClassLoader classLoader;
|
||||
private PropertyChangeSupport pcs;
|
||||
private static final String ENCODING = "UTF-8";
|
||||
private static final String DATE_FORMAT = "yyyy-MM-dd HH:mm:ss";
|
||||
private SimpleDateFormat dateFormatter;
|
||||
//used to specify default unique module order of autodiscovered modules
|
||||
//if not specified
|
||||
private int numModDiscovered = 0;
|
||||
private static String CUR_MODULES_DISCOVERED_SETTING = "curModulesDiscovered";
|
||||
|
||||
//events supported
|
||||
enum Event {
|
||||
@ -133,6 +136,17 @@ public final class IngestModuleLoader {
|
||||
filePipeline = new ArrayList<IngestModuleAbstractFile>();
|
||||
imagePipeline = new ArrayList<IngestModuleImage>();
|
||||
dateFormatter = new SimpleDateFormat(DATE_FORMAT);
|
||||
|
||||
String numModDiscoveredStr = ModuleSettings.getConfigSetting(IngestManager.MODULE_PROPERTIES, CUR_MODULES_DISCOVERED_SETTING);
|
||||
if (numModDiscoveredStr != null) {
|
||||
try {
|
||||
numModDiscovered = Integer.valueOf(numModDiscoveredStr);
|
||||
} catch (NumberFormatException e) {
|
||||
numModDiscovered = 0;
|
||||
logger.log(Level.WARNING, "Could not parse numModDiscovered setting, defaulting to 0", e);
|
||||
}
|
||||
}
|
||||
|
||||
pcs = new PropertyChangeSupport(this);
|
||||
registerModulesChange();
|
||||
}
|
||||
@ -345,15 +359,15 @@ public final class IngestModuleLoader {
|
||||
|
||||
/*
|
||||
* netbeans way, but not public API
|
||||
org.openide.filesystems.Repository defaultRepository = Repository.getDefault();
|
||||
FileSystem masterFilesystem = defaultRepository.getDefaultFileSystem();
|
||||
org.netbeans.core.startup.ModuleSystem moduleSystem = new org.netbeans.core.startup.ModuleSystem(masterFilesystem);
|
||||
List<File> jars = moduleSystem.getModuleJars();
|
||||
for (File jar : jars) {
|
||||
logger.log(Level.INFO, " JAR2: " + jar.getAbsolutePath());
|
||||
}
|
||||
//org.netbeans.ModuleManager moduleManager = moduleSystem.getManager();
|
||||
*/
|
||||
org.openide.filesystems.Repository defaultRepository = Repository.getDefault();
|
||||
FileSystem masterFilesystem = defaultRepository.getDefaultFileSystem();
|
||||
org.netbeans.core.startup.ModuleSystem moduleSystem = new org.netbeans.core.startup.ModuleSystem(masterFilesystem);
|
||||
List<File> jars = moduleSystem.getModuleJars();
|
||||
for (File jar : jars) {
|
||||
logger.log(Level.INFO, " JAR2: " + jar.getAbsolutePath());
|
||||
}
|
||||
//org.netbeans.ModuleManager moduleManager = moduleSystem.getManager();
|
||||
*/
|
||||
|
||||
return urls;
|
||||
}
|
||||
@ -580,11 +594,13 @@ public final class IngestModuleLoader {
|
||||
|
||||
/**
|
||||
* Set a new order of the module
|
||||
*
|
||||
* @param pipeLineType pipeline type where the module to reorder is present
|
||||
* @param moduleLocation loaded module name (location), fully qualified class path
|
||||
* @param moduleLocation loaded module name (location), fully qualified
|
||||
* class path
|
||||
* @param newOrder new order to set
|
||||
*/
|
||||
void setModuleOrder(XmlPipelineRaw.PIPELINE_TYPE pipeLineType, String moduleLocation, int newOrder) throws IngestModuleLoaderException{
|
||||
void setModuleOrder(XmlPipelineRaw.PIPELINE_TYPE pipeLineType, String moduleLocation, int newOrder) throws IngestModuleLoaderException {
|
||||
throw new IngestModuleLoaderException("Not yet implemented");
|
||||
}
|
||||
|
||||
@ -601,10 +617,13 @@ public final class IngestModuleLoader {
|
||||
XmlModuleRaw modRaw = new XmlModuleRaw();
|
||||
modRaw.arguments = ""; //default, no arguments
|
||||
modRaw.location = moduleLocation;
|
||||
modRaw.order = Integer.MAX_VALUE - (currentLast++); //add to end
|
||||
modRaw.order = Integer.MAX_VALUE - (numModDiscovered++); //add to end
|
||||
modRaw.type = XmlModuleRaw.MODULE_TYPE.PLUGIN.toString();
|
||||
modRaw.valid = false; //to be validated
|
||||
|
||||
//save the current numModDiscovered
|
||||
ModuleSettings.setConfigSetting(IngestManager.MODULE_PROPERTIES, CUR_MODULES_DISCOVERED_SETTING, Integer.toString(numModDiscovered));
|
||||
|
||||
//find the pipeline of that type
|
||||
XmlPipelineRaw pipeline = null;
|
||||
for (XmlPipelineRaw rawP : this.pipelinesXML) {
|
||||
@ -958,8 +977,11 @@ public final class IngestModuleLoader {
|
||||
try {
|
||||
module.order = Integer.parseInt(moduleOrder);
|
||||
} catch (NumberFormatException e) {
|
||||
logger.log(Level.WARNING, "Invalid module order, need integer: " + moduleOrder);
|
||||
module.order = Integer.MAX_VALUE - (currentLast++);
|
||||
logger.log(Level.WARNING, "Invalid module order, need integer: " + moduleOrder + ", adding to end of the list");
|
||||
module.order = Integer.MAX_VALUE - (numModDiscovered++);
|
||||
//save the current numModDiscovered
|
||||
ModuleSettings.setConfigSetting(IngestManager.MODULE_PROPERTIES, CUR_MODULES_DISCOVERED_SETTING, Integer.toString(numModDiscovered));
|
||||
|
||||
}
|
||||
module.type = moduleType;
|
||||
pipelineRaw.modules.add(module);
|
||||
|
@ -108,7 +108,7 @@ public class IngestServices {
|
||||
* Gets a configuration setting for a module
|
||||
* @param moduleName moduleName identifier unique to that module
|
||||
* @param settingName setting name to retrieve
|
||||
* @return setting value for the module / setting name
|
||||
* @return setting value for the module / setting name, or null if not found
|
||||
*/
|
||||
public String getConfigSetting(String moduleName, String settingName) {
|
||||
return ModuleSettings.getConfigSetting(moduleName, settingName);
|
||||
|
@ -1,5 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Contains only the modules that ship with Autopsy -->
|
||||
<!-- Default initial pipeline_config.xml
|
||||
Contains only the core ingest modules that ship with Autopsy -->
|
||||
<PIPELINE_CONFIG>
|
||||
<PIPELINE type="FileAnalysis">
|
||||
<MODULE order="1" type="plugin" location="org.sleuthkit.autopsy.hashdatabase.HashDbIngestModule" arguments="" />
|
||||
|
Loading…
x
Reference in New Issue
Block a user