diff --git a/volatility/cli/__init__.py b/volatility/cli/__init__.py index 805b65566..112c53bb3 100644 --- a/volatility/cli/__init__.py +++ b/volatility/cli/__init__.py @@ -41,28 +41,27 @@ class CommandLine(object): dldr = depresolver.DataLayerDependencyResolver() dependencies = dldr.build_tree(plugin) - # UI fills in the config: - ctx = contexts.Context() - ctx.config["pslist.primary.memory_layer.filename"] = "/run/media/mike/disk/memory/xp-laptop-2005-07-04-1430.img" - ctx.config["pslist.primary.page_map_offset"] = 0x39000 - - print(dldr.resolve_dependencies(dependencies, context = ctx, path = ["pslist"])) - # TODO: write functions that determine all possible options/requirements for this plugin # (flatten the tree, treating disjunctions as conjunctions) - print(list(dependencies)) + # print(list(dependencies)) # TODO: Write functions that walk the tree and produce instances of each of the requirements # (to allow a registry-like tree of config values that can be populated by the user) # TODO: Walk down the tree attempting to fulfil each requirement (recursive) and backtrack when necessary - - # Translate the parsed args to a context configuration - # Construct and run the plugin - # plugin(context).run() + + # UI fills in the config: + ctx = contexts.Context() + ctx.config["pslist.primary.memory_layer.filename"] = "/run/media/mike/disk/memory/xp-laptop-2005-07-04-1430.img" + ctx.config["pslist.primary.page_map_offset"] = 0x39000 + ctx.config["pslist.offset"] = 0x823c87c0 + + if dldr.validate_dependencies(dependencies, context = ctx, path = ["pslist"]): + # Construct and run the plugin + plugin(ctx).run() def main(): diff --git a/volatility/framework/configuration/depresolver.py b/volatility/framework/configuration/depresolver.py index fde52d453..f9c6e62f2 100644 --- a/volatility/framework/configuration/depresolver.py +++ b/volatility/framework/configuration/depresolver.py @@ -34,7 +34,7 @@ class DataLayerDependencyResolver(validity.ValidityRoutines): satisfied = satisfied and (layer_class.metadata[k] == v) return satisfied - def resolve_dependencies(self, deptree, context, path = None): + def validate_dependencies(self, deptree, context, path = None): """Takes a dependency tree and attempts to resolve the tree by validating each branch and using the first that successfully validates @param path: A list of path components to access the deptree's configuration details @@ -46,7 +46,7 @@ class DataLayerDependencyResolver(validity.ValidityRoutines): for node in deptree: if isinstance(node, Node) and not node.requirement.optional: for branch, subtree in node.branches.items(): - if self.resolve_dependencies(subtree, context, path = path + [node.requirement.name]): + if self.validate_dependencies(subtree, context, path = path + [node.requirement.name]): # Generate a layer name layer_name = node.requirement.name counter = 2 diff --git a/volatility/framework/interfaces/plugins.py b/volatility/framework/interfaces/plugins.py index f77dad73b..812ac4aa4 100644 --- a/volatility/framework/interfaces/plugins.py +++ b/volatility/framework/interfaces/plugins.py @@ -51,7 +51,7 @@ class PluginInterface(validity.ValidityRoutines, configuration_interface.Configu def validate_inputs(self): for option in self.get_schema(): if not option.optional: - option.validate_input(self.config.get_value(option.name), self.context) + option.validate(self.config.get_value(option.name), self.context) @abstractmethod def run(self):