From 1a0d1a238da02db679c0bc5dfa10191abe25b6b7 Mon Sep 17 00:00:00 2001 From: lesander <4174509+lesander@users.noreply.github.com> Date: Sun, 24 Nov 2024 09:28:41 +0000 Subject: [PATCH 1/2] CLI: Partial changes by @lesander contributed in #1343 --- .github/workflows/test.yaml | 4 ++-- volatility3/cli/__init__.py | 5 +++-- volatility3/cli/volshell/__init__.py | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 6358dd45d..73bf342b6 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -41,8 +41,8 @@ jobs: - name: Testing... run: | - py.test ./test/test_volatility.py --volatility=vol.py --image win-xp-laptop-2005-06-25.img -k test_windows -v - py.test ./test/test_volatility.py --volatility=vol.py --image linux-sample-1.bin -k test_linux -v + pytest ./test/test_volatility.py --volatility=vol.py --image win-xp-laptop-2005-06-25.img -k test_windows -v + pytest ./test/test_volatility.py --volatility=vol.py --image linux-sample-1.bin -k test_linux -v - name: Clean up post-test run: | diff --git a/volatility3/cli/__init__.py b/volatility3/cli/__init__.py index 75b62abf6..5b2aa2838 100644 --- a/volatility3/cli/__init__.py +++ b/volatility3/cli/__init__.py @@ -88,7 +88,7 @@ class MuteProgress(PrintedProgress): class CommandLine: """Constructs a command-line interface object for users to run plugins.""" - CLI_NAME = "volatility" + CLI_NAME = os.path.basename(sys.argv[0]) # vol or volatility def __init__(self): self.setup_logging() @@ -364,6 +364,7 @@ class CommandLine: self.CLI_NAME ), action=volargparse.HelpfulSubparserAction, + metavar="PLUGIN", ) for plugin in sorted(plugin_list): plugin_parser = subparser.add_parser( @@ -385,7 +386,7 @@ class CommandLine: argcomplete.autocomplete(parser) args = parser.parse_args() if args.plugin is None: - parser.error("Please select a plugin to run") + parser.error(f"Please select a plugin to run (see '{self.CLI_NAME} --help' for options") vollog.log( constants.LOGLEVEL_VVV, f"Cache directory used: {constants.CACHE_PATH}" diff --git a/volatility3/cli/volshell/__init__.py b/volatility3/cli/volshell/__init__.py index 5172c5363..559adc12b 100644 --- a/volatility3/cli/volshell/__init__.py +++ b/volatility3/cli/volshell/__init__.py @@ -49,7 +49,7 @@ class VolShell(cli.CommandLine): python terminal with all the volatility support calls available. """ - CLI_NAME = "volshell" + CLI_NAME = os.path.basename(sys.argv[0]) # volshell def __init__(self): super().__init__() From 523a6e92fc75a972fe5d9a73c6dc65d4322a7f46 Mon Sep 17 00:00:00 2001 From: Mike Auty Date: Sun, 24 Nov 2024 09:33:30 +0000 Subject: [PATCH 2/2] CLI: Apply black to recent changes --- volatility3/cli/__init__.py | 6 ++++-- volatility3/cli/volshell/__init__.py | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/volatility3/cli/__init__.py b/volatility3/cli/__init__.py index 5b2aa2838..901f299a8 100644 --- a/volatility3/cli/__init__.py +++ b/volatility3/cli/__init__.py @@ -88,7 +88,7 @@ class MuteProgress(PrintedProgress): class CommandLine: """Constructs a command-line interface object for users to run plugins.""" - CLI_NAME = os.path.basename(sys.argv[0]) # vol or volatility + CLI_NAME = os.path.basename(sys.argv[0]) # vol or volatility def __init__(self): self.setup_logging() @@ -386,7 +386,9 @@ class CommandLine: argcomplete.autocomplete(parser) args = parser.parse_args() if args.plugin is None: - parser.error(f"Please select a plugin to run (see '{self.CLI_NAME} --help' for options") + parser.error( + f"Please select a plugin to run (see '{self.CLI_NAME} --help' for options" + ) vollog.log( constants.LOGLEVEL_VVV, f"Cache directory used: {constants.CACHE_PATH}" diff --git a/volatility3/cli/volshell/__init__.py b/volatility3/cli/volshell/__init__.py index 559adc12b..e9d3fda08 100644 --- a/volatility3/cli/volshell/__init__.py +++ b/volatility3/cli/volshell/__init__.py @@ -49,7 +49,7 @@ class VolShell(cli.CommandLine): python terminal with all the volatility support calls available. """ - CLI_NAME = os.path.basename(sys.argv[0]) # volshell + CLI_NAME = os.path.basename(sys.argv[0]) # volshell def __init__(self): super().__init__()