restore the volatility banner on --help and missing-plugin invocations (#1979)#1983
Open
ChrisJr404 wants to merge 1 commit intovolatilityfoundation:developfrom
Open
restore the volatility banner on --help and missing-plugin invocations (#1979)#1983ChrisJr404 wants to merge 1 commit intovolatilityfoundation:developfrom
ChrisJr404 wants to merge 1 commit intovolatilityfoundation:developfrom
Conversation
volatilityfoundation#1979) Commit 8479fa1 moved the renderer/plugin discovery (and with it, the banner-print block) to after parser.parse_args(). That means $ vol.py --help $ vol.py # missing PLUGIN argument both exit through argparse before the banner is reached. Move just the banner write back above the subparser registration: at that point the renderer (`-r`) argument has been added but the PLUGIN positional has not, so parse_known_args(...) tolerates an empty / help / unknown-plugin invocation and we can pick the right output stream (stdout for the default `quick` renderer, stderr for structured renderers like JSON / parquet so they don't pollute pipeable output). Closes volatilityfoundation#1979.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1979.
Background
Per @eve-mem's bisection in the issue thread, commit 8479fa1 (PR #1861, "moved renderer parsing to after the plugins are imported") moved the banner-print block from before
parse_args()to after it:Since
argparse.parse_args()exits when handed--help/-h, and now exits with an error when thePLUGINpositional is missing, both common informational invocations skip the banner entirely.Constraint @ikelos called out
Change
Move just the banner write block back to between the renderer-arg registration and the subparser registration:
At this point in
run():-r) argument has been added, so the partial-parse picks up an explicit-r JSONetc.PLUGINsubparser positional has NOT been added yet, soparse_known_argsdoesn't rejectvol.py(or any unknown plugin name) — it falls into the discarded leftover slot exactly the way the existing partial-parse at line 257 relies onThe trailing
parser.parse_args()is unchanged and still does final argument validation +--helprendering; the banner just precedes its output now.Verification
flush()is added becauseargparse.exit()doesn't flush stdout before terminating, which would lose the banner underpython3 -u-less runs.Diff is
+12 / -0lines, single file, no public-API change.