diff --git a/volatility/framework/contexts/__init__.py b/volatility/framework/contexts/__init__.py index bad576e8d..f7adee174 100644 --- a/volatility/framework/contexts/__init__.py +++ b/volatility/framework/contexts/__init__.py @@ -99,9 +99,11 @@ class Context(interfaces.context.ContextInterface): offset = offset)) @functools.lru_cache() - def module(self, module_name: str, layer_name: str, offset: int) -> interfaces.context.Module: - """Create a module object """ - + def module(self, # type: ignore # FIXME: mypy #5107 + module_name: str, + layer_name: str, + offset: int) -> interfaces.context.Module: + """Creates a module object""" return Module(self, module_name, layer_name, offset) @@ -190,7 +192,7 @@ class ModuleCollection(validity.ValidityRoutines): for mod in self._modules: if mod.hash not in seen or mod.size == 0: new_modules.append(mod) - seen.add(mod.hash) + seen.add(mod.hash) # type: ignore # FIXME: mypy #5107 return ModuleCollection(new_modules) @property diff --git a/volatility/framework/interfaces/context.py b/volatility/framework/interfaces/context.py index 24ab3d458..40e023a22 100644 --- a/volatility/framework/interfaces/context.py +++ b/volatility/framework/interfaces/context.py @@ -126,15 +126,18 @@ class Module(validity.ValidityRoutines, metaclass = ABCMeta): """Layer name in which the Module resides""" return self._layer_name - @property + @property # type: ignore # FIXME: mypy #5107 @functools.lru_cache() def hash(self) -> str: """Hashes the module for equality checks The mapping should be sorted and should be quicker than reading the data We turn it into JSON to make a common string and use a quick hash, because collissions are unlikely""" + layer = self._context.memory[self.layer_name] + if not isinstance(layer, interfaces.layers.TranslationLayerInterface): + raise TypeError("Hashing modules on non-TranslationLayers is not allowed") return hashlib.md5( - str(list(self._context.memory[self.layer_name].mapping(self.offset, self.size, ignore_errors = True)))) + bytes(str(list(layer.mapping(self.offset, self.size, ignore_errors = True))), 'utf-8')).hexdigest() @abstractmethod def object(self, diff --git a/volatility/framework/objects/utility.py b/volatility/framework/objects/utility.py index 55e312733..000ef76bc 100644 --- a/volatility/framework/objects/utility.py +++ b/volatility/framework/objects/utility.py @@ -54,6 +54,7 @@ def wintime_to_datetime(wintime: int) -> typing.Union[ except ValueError: return renderers.UnparsableValue() + def round(addr, align, up = False): """Round an address up or down based on an alignment. diff --git a/volatility/framework/renderers/__init__.py b/volatility/framework/renderers/__init__.py index 52ae53b83..7d3c82554 100644 --- a/volatility/framework/renderers/__init__.py +++ b/volatility/framework/renderers/__init__.py @@ -29,6 +29,7 @@ class NotAvailableValue(interfaces.renderers.BaseAbsentValue): Unreadable and Unparsable should be used in preference, and only if neither fits should this be used. """ + class TreeNode(interfaces.renderers.TreeNode): """Class representing a particular node in a tree grid"""