From d08c29ffab52f1c1b352b146ea02cc8f71077e13 Mon Sep 17 00:00:00 2001 From: Mike Auty Date: Sun, 5 Aug 2018 16:18:53 +0100 Subject: [PATCH] Improve style to use default iterators rather than explicit ones. --- volatility/cli/volshell/shellplugin.py | 2 +- volatility/framework/objects/__init__.py | 2 +- volatility/framework/symbols/__init__.py | 2 +- volatility/framework/symbols/intermed.py | 8 ++++---- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/volatility/cli/volshell/shellplugin.py b/volatility/cli/volshell/shellplugin.py index 6b1d55df7..fca79edc4 100644 --- a/volatility/cli/volshell/shellplugin.py +++ b/volatility/cli/volshell/shellplugin.py @@ -28,7 +28,7 @@ class Volshell(interfaces.plugins.PluginInterface): config = self.config layer_name = self.config['primary'] kvo = context.memory[layer_name].config.get('kernel_virtual_offset') - members = lambda x: list(sorted(x.vol.members.keys())) + members = lambda x: list(sorted(x.vol.members)) # Determine locals curframe = inspect.currentframe() diff --git a/volatility/framework/objects/__init__.py b/volatility/framework/objects/__init__.py index 725221ea2..31a6953de 100644 --- a/volatility/framework/objects/__init__.py +++ b/volatility/framework/objects/__init__.py @@ -617,7 +617,7 @@ class Struct(interfaces.objects.ObjectInterface): def __dir__(self) -> typing.Iterable[str]: """Returns a complete list of members when dir is called""" - return list(super().__dir__()) + list(self.vol.members.keys()) + return list(super().__dir__()) + list(self.vol.members) def write(self, value): raise TypeError("Structs cannot be written to directly, individual members must be written instead") diff --git a/volatility/framework/symbols/__init__.py b/volatility/framework/symbols/__init__.py index b4e3d22b8..155a6e897 100644 --- a/volatility/framework/symbols/__init__.py +++ b/volatility/framework/symbols/__init__.py @@ -49,7 +49,7 @@ class SymbolSpace(interfaces.symbols.SymbolSpaceInterface, validity.ValidityRout def get_symbols_by_type(self, type_name: str) -> typing.Iterable[str]: """Returns all symbols based on the type of the symbol""" - for table in self._dict.keys(): + for table in self._dict: for symbol_name in self._dict[table].get_symbols_by_type(type_name): yield table + constants.BANG + symbol_name diff --git a/volatility/framework/symbols/intermed.py b/volatility/framework/symbols/intermed.py index cd3ab84a4..7c7fb5be8 100644 --- a/volatility/framework/symbols/intermed.py +++ b/volatility/framework/symbols/intermed.py @@ -109,7 +109,7 @@ class IntermediateSymbolTable(interfaces.symbols.SymbolTableInterface): changes have been made) than the consumer (in this case, the file reader). """ supported, age, revision = [int(x) for x in version.split(".")] - supported_versions = [x for x in versions.keys() if x[0] == supported and x[1] >= age] + supported_versions = [x for x in versions if x[0] == supported and x[1] >= age] if not supported_versions: raise ValueError( "No Intermediate Format interface versions support file interface version: {}".format(version)) @@ -258,17 +258,17 @@ class Version1Format(ISFormatTable): @property def symbols(self) -> typing.Iterable[str]: """Returns an iterator of the symbol names""" - return self._json_object.get('symbols', {}).keys() + return list(self._json_object.get('symbols', {})) @property def enumerations(self) -> typing.Iterable[str]: """Returns an iterator of the available enumerations""" - return self._json_object.get('enums', {}).keys() + return list(self._json_object.get('enums', {})) @property def types(self) -> typing.Iterable[str]: """Returns an iterator of the symbol type names""" - return list(self._json_object.get('user_types', {}).keys()) + list(self.natives.types) + return list(self._json_object.get('user_types', {})) + list(self.natives.types) def get_type_class(self, name: str) -> typing.Type[interfaces.objects.ObjectInterface]: return self._overrides.get(name, objects.Struct)