-
Notifications
You must be signed in to change notification settings - Fork 14.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Switch to using mod parameter for tab completion #14564
Switch to using mod parameter for tab completion #14564
Conversation
@msjenkins-r7 test this please. |
I went ahead and merged this locally, doing my best to fix the conflicts, but when I retested after the merge fix, I got:
I may have screwed it up in my attempts to fix the merge conflicts, though. |
@bwatters-r7 Thanks for testing this out; Looks like tab completion is broken in master after this change #14582 |
df377c7
to
ad8891d
Compare
Rebased and rested with your scenario 👍 |
@@ -118,8 +118,8 @@ def cmd_action_help(action) | |||
# at least 1 when tab completion has reached this stage since the command itself has been completed | |||
# | |||
def cmd_run_tabs(str, words) | |||
flags = @@run_action_opts.fmt.keys | |||
options = tab_complete_option(str, words) | |||
flags = @@module_opts.fmt.keys |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cc @zeroSteiner I'm thinking this was just a typo from #14582 👀
Master:
bundle exec ./msfconsole -q --logger Stdout
...
msf6 > use auxiliary/gather/jenkins_cred_recovery
[01/21/2021 23:03:19] [i(2)] core: Reloading auxiliary module gather/jenkins_cred_recovery. Ambiguous module warnings are safe to ignore
msf6 auxiliary(gather/jenkins_cred_recovery) > run rh<tab_here>
bundler: failed to load command: ./msfconsole (./msfconsole)
NameError: uninitialized class variable @@run_action_opts in Msf::Ui::Console::ModuleActionCommands
/Users/user/Documents/code/metasploit-framework/lib/msf/ui/console/module_action_commands.rb:121:in `cmd_run_tabs'
/Users/user/Documents/code/metasploit-framework/lib/rex/ui/text/dispatcher_shell.rb:444:in `tab_complete_helper'
/Users/user/Documents/code/metasploit-framework/lib/rex/ui/text/dispatcher_shell.rb:403:in `block in tab_complete_stub'
/Users/user/Documents/code/metasploit-framework/lib/rex/ui/text/dispatcher_shell.rb:392:in `each'
/Users/user/Documents/code/metasploit-framework/lib/rex/ui/text/dispatcher_shell.rb:392:in `tab_complete_stub'
/Users/user/Documents/code/metasploit-framework/lib/rex/ui/text/dispatcher_shell.rb:377:in `tab_complete'
/Users/user/Documents/code/metasploit-framework/lib/rex/ui/text/shell.rb:69:in `block in init_tab_complete'
/Users/user/.rvm/gems/ruby-2.7.2@metasploit-framework/gems/rb-readline-0.5.5/lib/readline.rb:136:in `readline_attempted_completion_function'
/Users/user/.rvm/gems/ruby-2.7.2@metasploit-framework/gems/rb-readline-0.5.5/lib/rbreadline.rb:6329:in `gen_completion_matches'
/Users/user/.rvm/gems/ruby-2.7.2@metasploit-framework/gems/rb-readline-0.5.5/lib/rbreadline.rb:6813:in `rl_complete_internal'
/Users/user/.rvm/gems/ruby-2.7.2@metasploit-framework/gems/rb-readline-0.5.5/lib/rbreadline.rb:6903:in `rl_complete'
/Users/user/.rvm/gems/ruby-2.7.2@metasploit-framework/gems/rb-readline-0.5.5/lib/rbreadline.rb:4374:in `_rl_dispatch_subseq'
/Users/user/.rvm/gems/ruby-2.7.2@metasploit-framework/gems/rb-readline-0.5.5/lib/rbreadline.rb:4363:in `_rl_dispatch'
/Users/user/.rvm/gems/ruby-2.7.2@metasploit-framework/gems/rb-readline-0.5.5/lib/rbreadline.rb:4779:in `readline_internal_charloop'
/Users/user/.rvm/gems/ruby-2.7.2@metasploit-framework/gems/rb-readline-0.5.5/lib/rbreadline.rb:4853:in `readline_internal'
/Users/user/.rvm/gems/ruby-2.7.2@metasploit-framework/gems/rb-readline-0.5.5/lib/rbreadline.rb:4875:in `readline'
/Users/user/Documents/code/metasploit-framework/lib/rex/ui/text/input/readline.rb:162:in `readline_with_output'
/Users/user/Documents/code/metasploit-framework/lib/rex/ui/text/input/readline.rb:100:in `pgets'
/Users/user/Documents/code/metasploit-framework/lib/rex/ui/text/shell.rb:321:in `get_input_line'
/Users/user/Documents/code/metasploit-framework/lib/rex/ui/text/shell.rb:141:in `run'
/Users/user/Documents/code/metasploit-framework/lib/metasploit/framework/command/console.rb:48:in `start'
/Users/user/Documents/code/metasploit-framework/lib/metasploit/framework/command/base.rb:82:in `start'
/Users/user/Documents/code/metasploit-framework/msfconsole:23:in `<top (required)>'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah it looks like I made a typo there. I think that's supposed to be @@module_action_opts
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assumed it was module_opts
as it's a superset of module_action_opts
? 🤔
metasploit-framework/lib/msf/ui/console/module_action_commands.rb
Lines 21 to 23 in ad8891d
@@module_opts = Rex::Parser::Arguments.new(@@module_action_opts.fmt.merge( | |
'-a' => [ true, 'The action to use. If none is specified, ACTION is used.'] | |
)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes if the action can be set in this context then the super set should be used. Do you want me to open a dedicated PR to fix this or roll it into these changes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed by: #14647
Release NotesUpdates internal Metasploit libraries to dependency inject the currently active module when performing tab completion for users |
This is a pre-requisite PR for future work. These functions will be used with an arbitrary module - not just the
active_module
that the implementation currently assumes. There should be no semantic changes for the end user as part of this PR.Verification
These are the same verification steps as #14240