mirror of
https://github.com/volatilityfoundation/volatility3.git
synced 2026-09-27 12:04:50 +02:00
A few additional typing fixes.
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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.
|
||||
|
||||
|
||||
@@ -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"""
|
||||
|
||||
|
||||
Reference in New Issue
Block a user