From eae84fd8e0b6100705d57ff4ac6beda922b268fe Mon Sep 17 00:00:00 2001 From: Mike Auty Date: Mon, 12 Dec 2016 02:05:29 +0000 Subject: [PATCH] Ensure we only stack when needed We shouldn't be stacking unless we're required, so now we run after the construction phase, and run our own construction phase is we've changed anything. --- volatility/framework/automagic/construct_layers.py | 7 +++++-- volatility/framework/automagic/stacker.py | 11 ++++++++++- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/volatility/framework/automagic/construct_layers.py b/volatility/framework/automagic/construct_layers.py index 8f1ed5388..6dbdeafcb 100644 --- a/volatility/framework/automagic/construct_layers.py +++ b/volatility/framework/automagic/construct_layers.py @@ -6,8 +6,11 @@ vollog = logging.getLogger(__name__) class ConstructionMagic(interfaces.automagic.AutomagicInterface): - """Runs through the requirement tree and from the bottom up attempts to construct all TranslationLayerRequirements""" - priority = 10 + """Runs through the requirement tree and from the bottom up attempts to construct all TranslationLayerRequirements + + This should run first to prevent existing configurations getting re-configured + """ + priority = 0 def __call__(self, context, config_path, requirement, optional = False): if not requirement.validate(context, config_path): diff --git a/volatility/framework/automagic/stacker.py b/volatility/framework/automagic/stacker.py index 73007202b..b31084a1c 100644 --- a/volatility/framework/automagic/stacker.py +++ b/volatility/framework/automagic/stacker.py @@ -2,18 +2,24 @@ from urllib import parse import volatility from volatility.framework import interfaces +from volatility.framework.automagic import construct_layers from volatility.framework.layers import physical class LayerStacker(interfaces.automagic.AutomagicInterface): """Class that attempts to build up """ # Most important automagic, must happen first! - priority = 0 + priority = 10 page_map_offset = None location = None def __call__(self, context, config_path, requirement): """Runs the automagic over the configurable""" + + # Quick exit if we're not needed + if requirement.validate(context, config_path): + return + # Bow out quickly if the UI hasn't provided a single_location if "automagic.general.single_location" not in context.config: return @@ -68,6 +74,9 @@ class LayerStacker(interfaces.automagic.AutomagicInterface): path, layer = result # splice in the new configuration into the original context context.config.splice(path, new_context.memory[layer].build_configuration()) + # Call the construction magic now we may have new things to construct + constructor = construct_layers.ConstructionMagic() + constructor(context, config_path, requirement) def find_suitable_requirements(self, stacked_layers, requirement, context, config_path): child_config_path = interfaces.configuration.path_join(config_path, requirement.name)