mirror of
https://github.com/volatilityfoundation/volatility3.git
synced 2026-09-13 21:27:39 +02:00
Refactor the build_configuration in Layers so that even data layers get their requirements populated.
This commit is contained in:
@@ -152,6 +152,19 @@ class DataLayerInterface(configuration.ConfigurableInterface, validity.ValidityR
|
||||
for x in scanner(chunk, offset):
|
||||
yield x
|
||||
|
||||
def build_configuration(self):
|
||||
config = super().build_configuration()
|
||||
|
||||
# Translation Layers are constructable, and therefore require a class configuration variable
|
||||
config["class"] = self.__class__.__module__ + "." + self.__class__.__name__
|
||||
for req in self.get_requirements():
|
||||
if isinstance(req, configuration.TranslationLayerRequirement):
|
||||
layer = self.config.get(req.name, None)
|
||||
if layer is not None:
|
||||
config.splice(req.name, self.context.memory[layer].build_configuration())
|
||||
# Delete the layer name, because is not part of the fixed config
|
||||
return config
|
||||
|
||||
|
||||
class TranslationLayerInterface(DataLayerInterface, metaclass = ABCMeta):
|
||||
# Unfortunately class attributes can't easily be inheritted from parent classes
|
||||
@@ -228,18 +241,6 @@ class TranslationLayerInterface(DataLayerInterface, metaclass = ABCMeta):
|
||||
for x in scanner(chunk, offset):
|
||||
yield x
|
||||
|
||||
def build_configuration(self):
|
||||
config = super().build_configuration()
|
||||
|
||||
# Translation Layers are constructable, and therefore require a class configuration variable
|
||||
config["class"] = self.__class__.__module__ + "." + self.__class__.__name__
|
||||
for req in self.get_requirements():
|
||||
if isinstance(req, configuration.TranslationLayerRequirement):
|
||||
layer = self.config.get(req.name, None)
|
||||
if layer is not None:
|
||||
config.splice(req.name, self.context.memory[layer].build_configuration())
|
||||
return config
|
||||
|
||||
|
||||
class Memory(validity.ValidityRoutines, collections.abc.Mapping):
|
||||
"""Container for multiple layers of data"""
|
||||
|
||||
Reference in New Issue
Block a user