From 31ddbaaa2ee8a3b5483b8cb71cebec5086e77f50 Mon Sep 17 00:00:00 2001 From: Mike Auty Date: Sat, 23 Nov 2019 20:40:40 +0000 Subject: [PATCH] Typing: Fix python3 format string/byte output issues --- volatility/framework/automagic/symbol_cache.py | 5 +++-- volatility/framework/configuration/requirements.py | 4 ++-- volatility/framework/interfaces/configuration.py | 2 +- volatility/framework/plugins/windows/poolscanner.py | 2 +- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/volatility/framework/automagic/symbol_cache.py b/volatility/framework/automagic/symbol_cache.py index 264960704..9791a984b 100644 --- a/volatility/framework/automagic/symbol_cache.py +++ b/volatility/framework/automagic/symbol_cache.py @@ -46,8 +46,9 @@ class SymbolBannerCache(interfaces.automagic.AutomagicInterface): for path in banners[banner]: url = urllib.parse.urlparse(path) if url.scheme == 'file' and not os.path.exists(urllib.request.url2pathname(url.path)): - vollog.log(constants.LOGLEVEL_VV, - "Removing cached path {} for banner {}: file does not exist".format(path, banner)) + vollog.log( + constants.LOGLEVEL_VV, "Removing cached path {} for banner {}: file does not exist".format( + path, str(banner, 'latin-1'))) banners[banner].remove(path) # This is probably excessive, but it's here if we need it # if url.scheme == 'jar': diff --git a/volatility/framework/configuration/requirements.py b/volatility/framework/configuration/requirements.py index 09919602c..b7794f4ff 100644 --- a/volatility/framework/configuration/requirements.py +++ b/volatility/framework/configuration/requirements.py @@ -272,7 +272,7 @@ class TranslationLayerRequirement(interfaces.configuration.ConstructableRequirem if value is not None: vollog.log(constants.LOGLEVEL_V, - "TypeError - Translation Layer Requirement only accepts string labels: {}".format(value)) + "TypeError - Translation Layer Requirement only accepts string labels: {}".format(repr(value))) return {config_path: self} # TODO: check that the space in the context lives up to the requirements for arch/os etc @@ -328,7 +328,7 @@ class SymbolTableRequirement(interfaces.configuration.ConstructableRequirementIn value = self.config_value(context, config_path, None) if not isinstance(value, str): vollog.log(constants.LOGLEVEL_V, - "TypeError - SymbolTableRequirement only accepts string labels: {}".format(value)) + "TypeError - SymbolTableRequirement only accepts string labels: {}".format(repr(value))) return {config_path: self} if value not in context.symbol_space: # This is an expected situation, so return False rather than raise diff --git a/volatility/framework/interfaces/configuration.py b/volatility/framework/interfaces/configuration.py index 3a05795ab..4d1c93200 100644 --- a/volatility/framework/interfaces/configuration.py +++ b/volatility/framework/interfaces/configuration.py @@ -439,7 +439,7 @@ class SimpleTypeRequirement(RequirementInterface): vollog.log( constants.LOGLEVEL_V, "TypeError - {} requirements only accept {} type: {}".format(self.name, self.instance_type.__name__, - value)) + repr(value))) return {config_path: self} return {} diff --git a/volatility/framework/plugins/windows/poolscanner.py b/volatility/framework/plugins/windows/poolscanner.py index d994be81f..667b3852f 100644 --- a/volatility/framework/plugins/windows/poolscanner.py +++ b/volatility/framework/plugins/windows/poolscanner.py @@ -398,7 +398,7 @@ class PoolScanner(plugins.PluginInterface): constraint_lookup = {} # type: Dict[bytes, PoolConstraint] for constraint in pool_constraints: if constraint.tag in constraint_lookup: - raise ValueError("Constraint tag is used for more than one constraint: {}".format(constraint.tag)) + raise ValueError("Constraint tag is used for more than one constraint: {}".format(repr(constraint.tag))) constraint_lookup[constraint.tag] = constraint module = cls._get_pool_header_module(context, layer_name, symbol_table)