Skip to content
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

Fix error handling when a plugin load fails #13012

Conversation

@adfoster-r7
Copy link
Contributor

adfoster-r7 commented Mar 2, 2020

This PR fixes error handling when a plugin load fails. The user is now correctly told the failure reason as expected.

Full context here: #12993 (comment)

Before:

msf5 > load wmap
[-] Error while running command load: wrong number of arguments (given 4, expected 1..3)

Call stack:
/Users/adfoster/Documents/code/metasploit-framework/lib/rex/logging/log_dispatcher.rb:137:in `elog'
/Users/adfoster/Documents/code/metasploit-framework/lib/msf/ui/console/command_dispatcher/core.rb:757:in `rescue in load_plugin'
/Users/adfoster/Documents/code/metasploit-framework/lib/msf/ui/console/command_dispatcher/core.rb:752:in `load_plugin'
/Users/adfoster/Documents/code/metasploit-framework/lib/msf/ui/console/command_dispatcher/core.rb:775:in `cmd_load'
/Users/adfoster/Documents/code/metasploit-framework/lib/rex/ui/text/dispatcher_shell.rb:523:in `run_command'
/Users/adfoster/Documents/code/metasploit-framework/lib/rex/ui/text/dispatcher_shell.rb:474:in `block in run_single'
/Users/adfoster/Documents/code/metasploit-framework/lib/rex/ui/text/dispatcher_shell.rb:468:in `each'
/Users/adfoster/Documents/code/metasploit-framework/lib/rex/ui/text/dispatcher_shell.rb:468:in `run_single'
/Users/adfoster/Documents/code/metasploit-framework/lib/rex/ui/text/shell.rb:158:in `run'
/Users/adfoster/Documents/code/metasploit-framework/lib/metasploit/framework/command/console.rb:48:in `start'
/Users/adfoster/Documents/code/metasploit-framework/lib/metasploit/framework/command/base.rb:82:in `start'
./msfconsole:49:in `<main>'

After:

msf5 > load wmap
[-] Failed to load plugin from /Users/adfoster/Documents/code/metasploit-framework/plugins/wmap: Database not connected (try db_connect)

Verification

List the steps needed to make sure this thing works

  • Start msfconsole without a database connected
  • load wmap
  • Verify the user is told the reason for failing to load a plugin: msf5 > load wmap [-] Failed to load plugin from /Users/adfoster/Documents/code/metasploit-framework/plugins/wmap: Database not connected (try db_connect)
  • Verify the user does not see an internal metasploit error: Error while running command load: wrong number of arguments (given 4, expected 1..3)
@dwelch-r7 dwelch-r7 self-assigned this Mar 2, 2020
@dwelch-r7 dwelch-r7 merged commit a2f2af7 into rapid7:master Mar 2, 2020
3 checks passed
3 checks passed
Metasploit Automation - Sanity Test Execution Successfully completed all tests.
Details
Metasploit Automation - Test Execution Successfully completed all tests.
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@dwelch-r7

This comment has been minimized.

Copy link
Contributor

dwelch-r7 commented Mar 2, 2020

Release Notes

This fixes the error handling for when a plugin fails to load. It now alerts the user to the failure reason.

@tperry-r7 tperry-r7 added the rn-fix label Mar 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

3 participants
You can’t perform that action at this time.