Convert SymbolTableInterfaces to descend from ConfigurableInterface

This allows SymbolTables to hold actual requirements (which
IntermedSymbolTable already did, but without pulling in the right
interface).  It means that values like kernel_virtual_offset get saved.

We still need to figure out how to allow plugins to demand optional
configuration values in other places (such as the kvo) but for now the
plugin will barf if it doesn't get it.
This commit is contained in:
Mike Auty
2016-12-12 02:08:32 +00:00
parent d43b294f36
commit ed716ca12a
3 changed files with 27 additions and 10 deletions
+18 -4
View File
@@ -6,6 +6,7 @@ Created on 4 May 2013
import bisect
from volatility.framework import constants, exceptions, validity
from volatility.framework.interfaces import configuration
class Symbol(validity.ValidityRoutines):
@@ -36,9 +37,7 @@ class Symbol(validity.ValidityRoutines):
return self._address
class SymbolTableInterface(validity.ValidityRoutines):
"""Handles a table of symbols"""
class BaseSymbolTableInterface(validity.ValidityRoutines):
def __init__(self, name, native_types = None):
self._check_type(native_types, NativeTableInterface)
if name:
@@ -132,7 +131,22 @@ class SymbolTableInterface(validity.ValidityRoutines):
yield closest_symbol.name
class NativeTableInterface(SymbolTableInterface):
class SymbolTableInterface(BaseSymbolTableInterface, configuration.ConfigurableInterface):
"""Handles a table of symbols"""
def __init__(self, context, config_path, name, native_types = None):
configuration.ConfigurableInterface.__init__(self, context, config_path)
BaseSymbolTableInterface.__init__(self, name, native_types)
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__
return config
class NativeTableInterface(BaseSymbolTableInterface):
"""Class to distinguish NativeSymbolLists from other symbol lists"""
def get_symbol(self, name):
+8 -5
View File
@@ -24,7 +24,7 @@ def _construct_delegate_function(name, is_property = False):
class IntermediateSymbolTable(interfaces.symbols.SymbolTableInterface):
def __init__(self, name, idd_filepath, native_types = None):
def __init__(self, context, config_path, name, idd_filepath, native_types = None):
# Check there are no obvious errors
url = urllib.parse.urlparse(idd_filepath)
if url.scheme != 'file':
@@ -47,11 +47,14 @@ class IntermediateSymbolTable(interfaces.symbols.SymbolTableInterface):
metadata = json_object.get('metadata', None)
# Determine the delegate or throw an exception
self._delegate = self._closest_version(metadata.get('format', "0.0.0"), self._versions)(name, json_object,
self._delegate = self._closest_version(metadata.get('format', "0.0.0"), self._versions)(context,
config_path,
name,
json_object,
native_types)
# Inherit
super().__init__(name, native_types or self._delegate.natives)
super().__init__(context, config_path, name, native_types or self._delegate.natives)
def _closest_version(self, version, versions):
"""Determines the highest suitable handler for specified version format"""
@@ -83,11 +86,11 @@ class Version1Format(ISFormatTable):
age = 1
version = (current - age, age, revision)
def __init__(self, name, json_object, native_types = None):
def __init__(self, context, config_path, name, json_object, native_types = None):
self._json_object = json_object
self._validate_json()
nt = native_types or self._get_natives()
super().__init__(name, nt)
super().__init__(context, config_path, name, nt)
self._overrides = {}
self._symbol_cache = None
@@ -9,7 +9,7 @@ class WindowsKernelIntermedSymbols(intermed.IntermediateSymbolTable):
provides = {"type": "interface"}
def __init__(self, context, config_path, name, idd_filepath):
super().__init__(name = name, idd_filepath = idd_filepath)
super().__init__(context = context, config_path = config_path, name = name, idd_filepath = idd_filepath)
# Set-up windows specific types
self.set_type_class('_ETHREAD', extensions._ETHREAD)