12
12
13
13
CHECK_OLD_RUBIES = !!ENV [ 'MSF_CHECK_OLD_RUBIES' ]
14
14
SUPPRESS_INFO_MESSAGES = !!ENV [ 'MSF_SUPPRESS_INFO_MESSAGES' ]
15
- TITLE_WHITELIST = %w{
16
- a an and as at avserve callmenum configdir connect debug docbase dtspcd
17
- execve file for from getinfo goaway gsad hetro historysearch htpasswd ibstat
18
- id in inetd iseemedia jhot libxslt lmgrd lnk load main map migrate mimencode
19
- multisort name net netcat nodeid ntpd nttrans of on onreadystatechange or
20
- ovutil path pbot pfilez pgpass pingstr pls popsubfolders prescan readvar
21
- relfile rev rexec rlogin rsh rsyslog sa sadmind say sblistpack spamd
22
- sreplace tagprinter the tnftp to twikidraw udev uplay user username via
23
- welcome with ypupdated zsudo
24
- }
25
15
26
16
if CHECK_OLD_RUBIES
27
17
require 'rvm'
@@ -215,6 +205,18 @@ def check_ref_identifiers
215
205
end
216
206
end
217
207
208
+ def check_self_class
209
+ in_register = false
210
+ @lines . each do |line |
211
+ ( in_register = true ) if line =~ /^\s *register_(?:advanced_)?options/
212
+ ( in_register = false ) if line =~ /^\s *end/
213
+ if in_register && line =~ /\] ,\s *self\. class\s *\) /
214
+ warn ( 'Explicitly using self.class in register_* is not necessary' )
215
+ break
216
+ end
217
+ end
218
+ end
219
+
218
220
# See if 'require "rubygems"' or equivalent is used, and
219
221
# warn if so. Since Ruby 1.9 this has not been necessary and
220
222
# the framework only suports 1.9+
@@ -227,6 +229,15 @@ def check_rubygems
227
229
end
228
230
end
229
231
232
+ def check_msf_core
233
+ @lines . each do |line |
234
+ if line_has_require? ( line , 'msf/core' )
235
+ warn ( 'Explicitly requiring/loading msf/core is not necessary' )
236
+ break
237
+ end
238
+ end
239
+ end
240
+
230
241
# Does the given line contain a require/load of the specified library?
231
242
def line_has_require? ( line , lib )
232
243
line =~ /^\s *(require|load)\s +['"]#{ lib } ['"]/
@@ -447,19 +458,6 @@ def check_disclosure_date
447
458
end
448
459
end
449
460
450
- def check_title_casing
451
- if @source =~ /["']Name["'][[:space:]]*=>[[:space:]]*['"](.+)['"],*$/
452
- words = $1. split
453
- words . each do |word |
454
- if TITLE_WHITELIST . include? ( word )
455
- next
456
- elsif word =~ /^[a-z]+$/
457
- warn ( "Suspect capitalization in module title: '#{ word } '" )
458
- end
459
- end
460
- end
461
- end
462
-
463
461
def check_bad_terms
464
462
# "Stack overflow" vs "Stack buffer overflow" - See explanation:
465
463
# http://blogs.technet.com/b/srd/archive/2009/01/28/stack-overflow-stack-exhaustion-not-the-same-as-stack-buffer-overflow.aspx
@@ -701,15 +699,16 @@ def run_checks
701
699
check_shebang
702
700
check_nokogiri
703
701
check_rubygems
702
+ check_msf_core
704
703
check_ref_identifiers
704
+ check_self_class
705
705
check_old_keywords
706
706
check_verbose_option
707
707
check_badchars
708
708
check_extname
709
709
check_old_rubies
710
710
check_ranking
711
711
check_disclosure_date
712
- check_title_casing
713
712
check_bad_terms
714
713
check_bad_super_class
715
714
check_bad_class_name
0 commit comments