Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions volatility3/cli/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,18 @@ def run(self):
choices=list(renderers),
)

# Display the banner BEFORE the subparser is added (so parse_known_args
# below treats unknown positionals as leftover instead of rejecting them
# against the PLUGIN choice list) and BEFORE parser.parse_args() runs at
# the bottom of this method (so the banner still appears when the user
# passes --help / -h, which causes argparse to print help and exit).
banner_partial_args, _ = parser.parse_known_args(known_args)
banner_output = sys.stdout
if renderers[banner_partial_args.renderer].structured_output:
banner_output = sys.stderr
banner_output.write(f"Volatility 3 Framework {constants.PACKAGE_VERSION}\n")
banner_output.flush()

seen_automagics = set()
chosen_configurables_list = {}
for amagic in automagics:
Expand Down Expand Up @@ -392,12 +404,6 @@ def run(self):
argcomplete.autocomplete(parser)
args = parser.parse_args()

# Display banner - redirect to stderr if using structured output
banner_output = sys.stdout
if renderers[args.renderer].structured_output:
banner_output = sys.stderr
banner_output.write(f"Volatility 3 Framework {constants.PACKAGE_VERSION}\n")

if args.plugin is None:
parser.error(
f"Please select a plugin to run (see '{self.CLI_NAME} --help' for options"
Expand Down
Loading