From 58e23657884454f6f6b5fac387a84bb7250fb140 Mon Sep 17 00:00:00 2001 From: Mike Auty Date: Tue, 8 Jul 2014 11:17:39 +0100 Subject: [PATCH] Add in initial requirements for plugins to state their inputs. --- volatility/framework/interfaces/plugins.py | 22 +++++++++++++++++++++- volatility/plugins/windows/pslist.py | 6 +++++- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/volatility/framework/interfaces/plugins.py b/volatility/framework/interfaces/plugins.py index 7e421d1ed..a618c4c20 100644 --- a/volatility/framework/interfaces/plugins.py +++ b/volatility/framework/interfaces/plugins.py @@ -30,11 +30,31 @@ class PluginInterface(validity.ValidityRoutines): def context(self): return self._context + @abstractmethod + @classmethod + def determine_inputs(cls): + """Returns the accepted inputs + + This should be a dictionary of TranslationLayer names matched to TranslationLayer types + """ + + def verify_inputs(self): + """Verifies the inputs basedo on the output of determine_inputs""" + inputs = self.determine_inputs() + for tl_name, tl_type in inputs.items(): + layer = self.context.memory.get(tl_name, None) + if layer is not None: + if layer.__class__.__name__ != tl_type: + raise TypeError("Layer " + tl_name + " is not of type " + tl_type + " (" + + layer.__class__.__name__ + " instead).") + else: + raise TypeError("Layer " + tl_name + " has not been populated.") + @abstractmethod def establish_context(self): """Alters the context to ensure the plugin can run. - This function constructs the necessary address spaces and symbol spaces that the plugin will need. + This function constructs the necessary symbol spaces that the plugin will need. """ @abstractmethod diff --git a/volatility/plugins/windows/pslist.py b/volatility/plugins/windows/pslist.py index 0f68cace3..193a77940 100644 --- a/volatility/plugins/windows/pslist.py +++ b/volatility/plugins/windows/pslist.py @@ -2,4 +2,8 @@ import volatility.framework.interfaces.plugins as plugins class pslist(plugins.PluginInterface): - pass + + @classmethod + def determine_inputs(cls): + return {"primary":"Intel"} +