Skip to content

Commit 79662be

Browse files
committed
2 parents 00b16ee + 9bf55ef commit 79662be

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

tools/msftidy.rb

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -536,8 +536,8 @@ def check_lines
536536
# RM#8498 for discussion, starting at comment #16:
537537
#
538538
# https://dev.metasploit.com/redmine/issues/8498#note-16
539-
if ln =~ /(?<!\.)datastore\[["'][^"']+["']\]\s*=(?![=~>])/
540-
info("datastore is modified in code: #{ln}", idx)
539+
if ln =~ /(?<!\.)datastore\[["'][^"']+["']\]\s*(=|<<)(?![=~>])/
540+
info("datastore is modified in code with '#{Regexp.last_match(1)}': #{ln}", idx)
541541
end
542542

543543
# do not read Set-Cookie header (ignore commented lines)
@@ -549,6 +549,10 @@ def check_lines
549549
if ln =~ /^\s*Rank\s*=\s*/ and @source =~ /<\sMsf::Auxiliary/
550550
warn("Auxiliary modules have no 'Rank': #{ln}", idx)
551551
end
552+
553+
if ln =~ /^\s*def\s+(?:[^\(\)]*[A-Z]+[^\(\)]*)(?:\(.*\))?$/
554+
warn("Please use snake case on method names: #{ln}", idx)
555+
end
552556
end
553557
end
554558

@@ -586,6 +590,19 @@ def check_udp_sock_get
586590
end
587591
end
588592

593+
# At one point in time, somebody committed a module with a bad metasploit.com URL
594+
# in the header -- http//metasploit.com/download rather than http://metasploit.com/download.
595+
# This module then got copied and committed 20+ times and is used in numerous other places.
596+
# This ensures that this stops.
597+
def check_invalid_url_scheme
598+
test = @source.scan(/^#.+http\/\/metasploit.com/)
599+
unless test.empty?
600+
test.each { |item|
601+
info("Invalid URL: #{item}")
602+
}
603+
end
604+
end
605+
589606
private
590607

591608
def load_file(file)
@@ -634,6 +651,7 @@ def run_checks(full_filepath)
634651
tidy.check_newline_eof
635652
tidy.check_sock_get
636653
tidy.check_udp_sock_get
654+
tidy.check_invalid_url_scheme
637655
return tidy
638656
end
639657

0 commit comments

Comments
 (0)