From 708d9330216853bfebcaa9d5799053656e422e10 Mon Sep 17 00:00:00 2001 From: Abyss Watcher Date: Wed, 23 Oct 2024 21:23:14 +0200 Subject: [PATCH 1/2] use additional_locals in run method --- volatility3/cli/volshell/generic.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/volatility3/cli/volshell/generic.py b/volatility3/cli/volshell/generic.py index c1ca7b5fa..39a7aa126 100644 --- a/volatility3/cli/volshell/generic.py +++ b/volatility3/cli/volshell/generic.py @@ -58,7 +58,7 @@ class Volshell(interfaces.plugins.PluginInterface): ] def run( - self, additional_locals: Dict[str, Any] = None + self, additional_locals: Dict[str, Any] = {} ) -> interfaces.renderers.TreeGrid: """Runs the interactive volshell plugin. @@ -94,7 +94,10 @@ class Volshell(interfaces.plugins.PluginInterface): """ sys.ps1 = f"({self.current_layer}) >>> " - self.__console = code.InteractiveConsole(locals=self._construct_locals_dict()) + # Dict self._construct_locals_dict() will have priority on keys + combined_locals = self._construct_locals_dict().copy() + combined_locals.update(additional_locals) + self.__console = code.InteractiveConsole(locals=combined_locals) # Since we have to do work to add the option only once for all different modes of volshell, we can't # rely on the default having been set if self.config.get("script", None) is not None: From 7f2d8eabb7f513148a7868d9a758c10f43d0450b Mon Sep 17 00:00:00 2001 From: Abyss Watcher Date: Wed, 23 Oct 2024 21:39:57 +0200 Subject: [PATCH 2/2] set correct locals priority --- volatility3/cli/volshell/generic.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/volatility3/cli/volshell/generic.py b/volatility3/cli/volshell/generic.py index 39a7aa126..a0477656e 100644 --- a/volatility3/cli/volshell/generic.py +++ b/volatility3/cli/volshell/generic.py @@ -95,8 +95,8 @@ class Volshell(interfaces.plugins.PluginInterface): sys.ps1 = f"({self.current_layer}) >>> " # Dict self._construct_locals_dict() will have priority on keys - combined_locals = self._construct_locals_dict().copy() - combined_locals.update(additional_locals) + combined_locals = additional_locals.copy() + combined_locals.update(self._construct_locals_dict()) self.__console = code.InteractiveConsole(locals=combined_locals) # Since we have to do work to add the option only once for all different modes of volshell, we can't # rely on the default having been set