Files
volatility3/volatility/framework/automagic/__init__.py
T
Mike Auty 14c0cc262c Significantly rework the configuration system.
So this is where I ripped out the guts of the dependency tree
and made it a little better defined in some ways, and delayed
populating it in others.  The validate function signature has
changed and I'm still up in the air whether to validate with
True/False or throw/catch exceptions.

So now, configurables have a list of requirements, these are
then bundled into a single requirement and can be passed to
automagic.  Automagic runs a set of things over the deptree
to help build/manage it.  These run in order of priority.

The tree is still built from the top down, but now automagic
can build branch from the bottom up and try and splice them
into the tree where appropriate.  Hopefully this will make it
easier to see follow.
2016-07-29 03:24:52 +01:00

30 lines
1.4 KiB
Python

import sys
from volatility.framework import class_subclasses, import_files
from volatility.framework.configuration import MultiRequirement
from volatility.framework.interfaces import automagic as automagic_interface
from volatility.framework.interfaces.configuration import ConfigurableInterface
def automagic(context, configurable, config_path = ""):
"""Runs through all the appropriate automagic capabilities on the configurable
This is where any automagic is allowed to run, and alter the context in order to satisfy/improve all requirements
"""
import_files(sys.modules[__name__])
if not isinstance(configurable, ConfigurableInterface) and not issubclass(configurable, ConfigurableInterface):
raise TypeError("Automagic operates on configurables only")
automagics = [clazz() for clazz in class_subclasses(automagic_interface.AutomagicInterface)]
# TODO: Fix need for top level config element just because we're using a MultiRequirement to group the
# configurable's config requirements
configurable_class = configurable
if isinstance(configurable, ConfigurableInterface):
configurable_class = configurable.__class__
requirement = MultiRequirement(name = configurable_class.__name__.lower())
for req in configurable.get_requirements():
requirement.add_requirement(req)
for automagic in sorted(automagics, key = lambda x: x.priority):
automagic(context, requirement, config_path)