mirror of
https://github.com/volatilityfoundation/volatility3.git
synced 2026-09-07 10:17:38 +02:00
Rework the CLI a little to actually call the plugin, but the config system needs improving/fixing/rewriting. 5:S
This commit is contained in:
+11
-12
@@ -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():
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user