rapid7/metasploit-framework — pull request #895 by wchen-r7 (2012-10-12 14:26:36+00:00)
Title: Multiple improvements for msftidy.rb

This pull request has a lot of changes, but most importantly it's meant to address these three things:

* check_single_file() is broken down into smaller functions (in a msftidy class) for better organization and readability.
* Display the line number for line-specific mistakes. For example: When a "Spaces at EOL" mistake is caught, it should always display the line number, that way it's easier to find.
* Depreciate the use of show_count() and show_missing(), and use warn() and error() instead, because these are the types of messages we show anyways. The new functions also favor showing the line number (of where the mistake is), instead of a count.

Other changes are sort of minor.

How to test:

You can simply run msftidy.rb against a module directory and test them all, like this:

/msf/tools/msftidy.rb /msf/modules/exploits

Or, you can use this test-case here:
http://pastebin.com/bYMuC8me

Demo:

$ /msf/tools/msftidy.rb test.rb
test.rb - [ERROR] Invalid ranking. You have 'AAAAAANormalRanking'
test.rb - [ERROR] Incorrect disclosure month format
test.rb - [WARNING] Improper capitalization in module title: 'microsoft...'
test.rb - [WARNING] Poorly designed argument list in 'fake_func()'. Try a hash.
test.rb:24 - [WARNING] Spaces at EOL
test.rb:25 - [WARNING] Spaces at EOL
test.rb:25 - [WARNING] Bad indent: " \t\t\t'Name' => 'microsoft Internet Explorer Fixed Table Col Span Heap Overflow', \n"
test.rb:29 - [WARNING] Bad indent: " \t\t\t\twhen they are modified dynamically by javascript code.\n"
test.rb:31 - [WARNING] Bad indent: " \t\t\t'License' => MSF_LICENSE,\n"
test.rb:76 - [WARNING] Spaces at EOL
test.rb:87 - [WARNING] Spaces at EOL
test.rb:88 - [ERROR] Writes to stdout
test.rb:122 - [WARNING] Bad indent: "\t\t \t\t\t\t0x77c15ed5, # xchg eax,esp; retn (pivot)\n"
test.rb:128 - [WARNING] Bad indent: "\t \t\t\t\t\t0x77c4ec00, # pop ebp; retn\n"
test.rb:135 - [WARNING] Bad indent: "\t\t \t\t\t\t0x77c46101, # rop nop (-> edi)\n"
test.rb:149 - [WARNING] Bad indent: "\t\t \t\t\t\t0x7c348b05, # xchg eax,esp; retn (pivot)\n"
test.rb:156 - [WARNING] Bad indent: "\t\t \t\t\t\t0x7c361829, # pop ecx ; retn [MSVCR71.dll]\n"
test.rb:158 - [WARNING] Bad indent: "\t\t \t\t\t\t0x7c342766, # pop edi ; retn [MSVCR71.dll]\n"
test.rb:160 - [WARNING] Spaces at EOL
test.rb:163 - [WARNING] Bad indent: "\t \t\t\t\t\t0x7c37a151, # ptr to &VirtualProtect() - 0x0ef [IAT msvcr71.dll]\n"
test.rb:169 - [WARNING] Spaces at EOL
test.rb:170 - [WARNING] Spaces at EOL
test.rb:173 - [WARNING] Spaces at EOL
test.rb:279 - [WARNING] Bad indent: " \tend\n"