Merge pull request #4389 from APriestman/4454_pythonModule

4454 Removed custom ingest settings from python example
This commit is contained in:
Richard Cordovano 2018-12-18 11:44:42 -05:00 committed by GitHub
commit 67acecc42d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 26 deletions

View File

@ -89,6 +89,7 @@ This section lists some helpful tips that we have found. These are all now in t
- We haven't found a good way to debug while running inside of Autopsy. So, logging becomes critical. You need to go through a bunch of steps to get the logger to display your module name. See the sample module for a log() method that does all of this for you. - We haven't found a good way to debug while running inside of Autopsy. So, logging becomes critical. You need to go through a bunch of steps to get the logger to display your module name. See the sample module for a log() method that does all of this for you.
- When you name the file with your Python module in it, restrict its name to letters, numbers, and underscore (_). - When you name the file with your Python module in it, restrict its name to letters, numbers, and underscore (_).
- Python modules using external libraries which load native code (SciPy, NumPy, etc.) are currently NOT supported. RuntimeError will be thrown. - Python modules using external libraries which load native code (SciPy, NumPy, etc.) are currently NOT supported. RuntimeError will be thrown.
- If your module needs ingest job settings, you must use the GenericIngestModuleJobSettings class instead of making a custom IngestModuleIngestJobSettings class
\section mod_dev_py_distribute Distribution \section mod_dev_py_distribute Distribution

View File

@ -48,6 +48,7 @@ from org.sleuthkit.autopsy.casemodule import Case
from org.sleuthkit.autopsy.casemodule.services import Services from org.sleuthkit.autopsy.casemodule.services import Services
from org.sleuthkit.autopsy.ingest import DataSourceIngestModule from org.sleuthkit.autopsy.ingest import DataSourceIngestModule
from org.sleuthkit.autopsy.ingest import FileIngestModule from org.sleuthkit.autopsy.ingest import FileIngestModule
from org.sleuthkit.autopsy.ingest import GenericIngestModuleJobSettings
from org.sleuthkit.autopsy.ingest import IngestMessage from org.sleuthkit.autopsy.ingest import IngestMessage
from org.sleuthkit.autopsy.ingest import IngestModule from org.sleuthkit.autopsy.ingest import IngestModule
from org.sleuthkit.autopsy.ingest.IngestModule import IngestModuleException from org.sleuthkit.autopsy.ingest.IngestModule import IngestModuleException
@ -82,16 +83,17 @@ class SampleFileIngestModuleWithUIFactory(IngestModuleFactoryAdapter):
# TODO: Update class name to one that you create below # TODO: Update class name to one that you create below
def getDefaultIngestJobSettings(self): def getDefaultIngestJobSettings(self):
return SampleFileIngestModuleWithUISettings() return GenericIngestModuleJobSettings()
# TODO: Keep enabled only if you need ingest job-specific settings UI # TODO: Keep enabled only if you need ingest job-specific settings UI
def hasIngestJobSettingsPanel(self): def hasIngestJobSettingsPanel(self):
return True return True
# TODO: Update class names to ones that you create below # TODO: Update class names to ones that you create below
# Note that you must use GenericIngestModuleJobSettings instead of making a custom settings class.
def getIngestJobSettingsPanel(self, settings): def getIngestJobSettingsPanel(self, settings):
if not isinstance(settings, SampleFileIngestModuleWithUISettings): if not isinstance(settings, GenericIngestModuleJobSettings):
raise IllegalArgumentException("Expected settings argument to be instanceof SampleIngestModuleSettings") raise IllegalArgumentException("Expected settings argument to be instanceof GenericIngestModuleJobSettings")
self.settings = settings self.settings = settings
return SampleFileIngestModuleWithUISettingsPanel(self.settings) return SampleFileIngestModuleWithUISettingsPanel(self.settings)
@ -124,7 +126,7 @@ class SampleFileIngestModuleWithUI(FileIngestModule):
# TODO: Add any setup code that you need here. # TODO: Add any setup code that you need here.
def startUp(self, context): def startUp(self, context):
# As an example, determine if user configured a flag in UI # As an example, determine if user configured a flag in UI
if self.local_settings.getFlag(): if self.local_settings.getSetting("flag") == "true":
self.log(Level.INFO, "flag is set") self.log(Level.INFO, "flag is set")
else: else:
self.log(Level.INFO, "flag is not set") self.log(Level.INFO, "flag is not set")
@ -144,25 +146,6 @@ class SampleFileIngestModuleWithUI(FileIngestModule):
def shutDown(self): def shutDown(self):
pass pass
# Stores the settings that can be changed for each ingest job
# All fields in here must be serializable. It will be written to disk.
# TODO: Rename this class
class SampleFileIngestModuleWithUISettings(IngestModuleIngestJobSettings):
serialVersionUID = 1L
def __init__(self):
self.flag = False
def getVersionNumber(self):
return serialVersionUID
# TODO: Define getters and settings for data you want to store from UI
def getFlag(self):
return self.flag
def setFlag(self, flag):
self.flag = flag
# UI that is shown to user for each ingest job so they can configure the job. # UI that is shown to user for each ingest job so they can configure the job.
# TODO: Rename this # TODO: Rename this
@ -187,9 +170,9 @@ class SampleFileIngestModuleWithUISettingsPanel(IngestModuleIngestJobSettingsPan
# TODO: Update this for your UI # TODO: Update this for your UI
def checkBoxEvent(self, event): def checkBoxEvent(self, event):
if self.checkbox.isSelected(): if self.checkbox.isSelected():
self.local_settings.setFlag(True) self.local_settings.setSetting("flag", "true")
else: else:
self.local_settings.setFlag(False) self.local_settings.setSetting("flag", "false")
# TODO: Update this for your UI # TODO: Update this for your UI
def initComponents(self): def initComponents(self):
@ -199,7 +182,7 @@ class SampleFileIngestModuleWithUISettingsPanel(IngestModuleIngestJobSettingsPan
# TODO: Update this for your UI # TODO: Update this for your UI
def customizeComponents(self): def customizeComponents(self):
self.checkbox.setSelected(self.local_settings.getFlag()) self.checkbox.setSelected(self.local_settings.getSetting("flag") == "true")
# Return the settings used # Return the settings used
def getSettings(self): def getSettings(self):