From 196bf8187dbb777f0ad43b2c9d18a0d9e069fe7d Mon Sep 17 00:00:00 2001 From: David McDonald Date: Fri, 14 Mar 2025 12:21:11 -0500 Subject: [PATCH] Volshell: Address comments from code review - Add failure message when readline or rlcompleter can't be imported - Fix unclosed file handle in context manager --- volatility3/cli/volshell/generic.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/volatility3/cli/volshell/generic.py b/volatility3/cli/volshell/generic.py index c86e221f7..143e26500 100644 --- a/volatility3/cli/volshell/generic.py +++ b/volatility3/cli/volshell/generic.py @@ -90,7 +90,9 @@ class Volshell(interfaces.plugins.PluginInterface): readline.parse_and_bind("tab: complete") print("Readline imported successfully") except ImportError: - pass + print( + "Readline or rlcompleter module could not be imported. Tab completion will not be available." + ) # TODO: provide help, consider generic functions (pslist?) and/or providing windows/linux functions @@ -539,7 +541,9 @@ class Volshell(interfaces.plugins.PluginInterface): location = "file:" + request.pathname2url(location) print(f"Running code from {location}\n") accessor = resources.ResourceAccessor() - with io.TextIOWrapper(accessor.open(url=location), encoding="utf-8") as fp: + with accessor.open(url=location) as handle, io.TextIOWrapper( + handle, encoding="utf-8" + ) as fp: if has_ipython: self.__console.ex(fp.read()) else: