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

Clarify "NameError: wrong constant name" message on invalid module name #10788

Merged
merged 3 commits into from Oct 10, 2018

Conversation

Projects
None yet
2 participants
@wvu-r7
Contributor

wvu-r7 commented Oct 10, 2018

This rescues the NameError and prints a more friendly error message when the generated constant is invalid due to unacceptable characters.

Not everyone is using msftidy, especially for personal modules. Not everyone knows the standard either.

Unfortunately, the nice WARNING! The following modules could not be loaded! message happens in the console layer, and we're stuck in the middle of module loading. I would like to remove the stack trace eventually.

wvu@kharak:~/metasploit-framework:feature/namespace$ ./msfconsole -q
Traceback (most recent call last):
	30: from ./msfconsole:49:in `<main>'
	29: from /Users/wvu/metasploit-framework/lib/metasploit/framework/command/base.rb:82:in `start'
	28: from /Users/wvu/metasploit-framework/lib/metasploit/framework/command/console.rb:48:in `start'
	27: from /Users/wvu/metasploit-framework/lib/metasploit/framework/command/console.rb:62:in `driver'
	26: from /Users/wvu/metasploit-framework/lib/metasploit/framework/command/console.rb:62:in `new'
	25: from /Users/wvu/metasploit-framework/lib/msf/ui/console/driver.rb:161:in `initialize'
	24: from /Users/wvu/metasploit-framework/lib/msf/base/simple/framework/module_paths.rb:49:in `init_module_paths'
	23: from /Users/wvu/metasploit-framework/lib/msf/base/simple/framework/module_paths.rb:49:in `each'
	22: from /Users/wvu/metasploit-framework/lib/msf/base/simple/framework/module_paths.rb:50:in `block in init_module_paths'
	21: from /Users/wvu/metasploit-framework/lib/msf/core/module_manager/module_paths.rb:40:in `add_module_path'
	20: from /Users/wvu/metasploit-framework/lib/msf/core/module_manager/module_paths.rb:40:in `each'
	19: from /Users/wvu/metasploit-framework/lib/msf/core/module_manager/module_paths.rb:41:in `block in add_module_path'
	18: from /Users/wvu/metasploit-framework/lib/msf/core/module_manager/loading.rb:117:in `load_modules'
	17: from /Users/wvu/metasploit-framework/lib/msf/core/module_manager/loading.rb:117:in `each'
	16: from /Users/wvu/metasploit-framework/lib/msf/core/module_manager/loading.rb:119:in `block in load_modules'
	15: from /Users/wvu/metasploit-framework/lib/msf/core/modules/loader/base.rb:238:in `load_modules'
	14: from /Users/wvu/metasploit-framework/lib/msf/core/modules/loader/directory.rb:30:in `each_module_reference_name'
	13: from /Users/wvu/metasploit-framework/lib/msf/core/modules/loader/directory.rb:30:in `foreach'
	12: from /Users/wvu/metasploit-framework/lib/msf/core/modules/loader/directory.rb:40:in `block in each_module_reference_name'
	11: from /Users/wvu/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/rex-core-0.1.13/lib/rex/file.rb:132:in `find'
	10: from /Users/wvu/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/rex-core-0.1.13/lib/rex/file.rb:132:in `catch'
	 9: from /Users/wvu/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/rex-core-0.1.13/lib/rex/file.rb:133:in `block in find'
	 8: from /Users/wvu/metasploit-framework/lib/msf/core/modules/loader/directory.rb:49:in `block (2 levels) in each_module_reference_name'
	 7: from /Users/wvu/metasploit-framework/lib/msf/core/modules/loader/base.rb:239:in `block in load_modules'
	 6: from /Users/wvu/metasploit-framework/lib/msf/core/modules/loader/base.rb:177:in `load_module'
	 5: from /Users/wvu/metasploit-framework/lib/msf/core/modules/loader/base.rb:542:in `namespace_module_transaction'
	 4: from /Users/wvu/metasploit-framework/lib/msf/core/modules/loader/base.rb:365:in `current_module'
	 3: from /Users/wvu/metasploit-framework/lib/msf/core/modules/loader/base.rb:365:in `reduce'
	 2: from /Users/wvu/metasploit-framework/lib/msf/core/modules/loader/base.rb:365:in `each'
	 1: from /Users/wvu/metasploit-framework/lib/msf/core/modules/loader/base.rb:370:in `block in current_module'
/Users/wvu/metasploit-framework/lib/msf/core/modules/loader/base.rb:380:in `rescue in block in current_module': exploit/windows/smb/my-ms17_010_eternalblue must be lowercase alphanumeric snake case (Msf::ModuleLoadError)
wvu@kharak:~/metasploit-framework:feature/namespace$

Resolves #10780. Updates #10729.

wvu-r7 added some commits Oct 10, 2018

@wvu-r7 wvu-r7 requested a review from busterb Oct 10, 2018

@busterb busterb self-assigned this Oct 10, 2018

@wvu-r7 wvu-r7 added enhancement and removed delayed labels Oct 10, 2018

@wvu-r7 wvu-r7 changed the title from Improve upon msftidy check for invalid module names to Clarify "NameError: wrong constant name" message on invalid module name Oct 10, 2018

@busterb busterb merged commit 0b89267 into rapid7:master Oct 10, 2018

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

busterb added a commit that referenced this pull request Oct 10, 2018

@wvu-r7

This comment has been minimized.

Show comment
Hide comment
@wvu-r7

wvu-r7 Oct 10, 2018

Contributor

Release Notes

This clarifies the NameError: wrong constant name message for invalid module names by rescuing the error and printing a friendlier one. The error can occur when the generated constant is invalid due to unacceptable characters such as -. This is meant to augment the msftidy check.

Contributor

wvu-r7 commented Oct 10, 2018

Release Notes

This clarifies the NameError: wrong constant name message for invalid module names by rescuing the error and printing a friendlier one. The error can occur when the generated constant is invalid due to unacceptable characters such as -. This is meant to augment the msftidy check.

@wvu-r7 wvu-r7 deleted the wvu-r7:feature/namespace branch Oct 10, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment