@@ -21,6 +21,10 @@ def red
21
21
def yellow
22
22
"\e [1;33;40m#{ self } \e [0m"
23
23
end
24
+
25
+ def ascii_only?
26
+ self =~ Regexp . new ( '[\x00-\x08\x0b\x0c\x0e-\x19\x7f-\xff]' , nil , 'n' ) ? false : true
27
+ end
24
28
end
25
29
26
30
class Msftidy
@@ -171,7 +175,7 @@ def check_badchars
171
175
end
172
176
173
177
if not mod_title . ascii_only?
174
- error ( "Please avoid unicode in module title." )
178
+ error ( "Please avoid unicode or non-printable characters in module title." )
175
179
end
176
180
177
181
# Since we're looking at the module title, this line clearly cannot be
@@ -184,22 +188,27 @@ def check_badchars
184
188
#
185
189
if in_super and !in_author and line =~ /'Author'[[:space:]]*=>/
186
190
in_author = true
187
- elsif in_super and in_author and line =~ /\] ,*\n /
191
+ elsif in_super and in_author and line =~ /\] ,*\n / or line =~ /['"][[:print:]]*['"][[:space:]]*=>/
188
192
in_author = false
189
193
end
190
194
191
195
192
196
#
193
197
# While in 'Author' block, check for Twitter handles
194
198
#
195
- if in_super and in_author and line =~ /['|"](.+)['|"]/
196
- author_name = $1
199
+ if in_super and in_author
200
+ if line =~ /Author/
201
+ author_name = line . scan ( /\[ [[:space:]]*['"](.+)['"]/ ) . flatten [ -1 ] || ''
202
+ else
203
+ author_name = line . scan ( /['"](.+)['"]/ ) . flatten [ -1 ] || ''
204
+ end
205
+
197
206
if author_name =~ /^@.+$/
198
207
error ( "No Twitter handle, please. Try leaving it in a comment instead." )
199
208
end
200
209
201
210
if not author_name . ascii_only?
202
- error ( "Please avoid unicode in Author" )
211
+ error ( "Please avoid unicode or non-printable characters in Author" )
203
212
end
204
213
end
205
214
end
@@ -246,7 +255,7 @@ def check_disclosure_date
246
255
return if @source =~ /Generic Payload Handler/ or @source !~ / \< Msf::Exploit/
247
256
248
257
# Check disclosure date format
249
- if @source =~ /'DisclosureDate'.*\= \> [\x0d | \x20 ]*['| \" ](.+)['| \" ]/
258
+ if @source =~ /'DisclosureDate'.*\= \> [\x0d \x20 ]*['\" ](.+)['\" ]/
250
259
d = $1 #Captured date
251
260
# Flag if overall format is wrong
252
261
if d =~ /^... \d {1,2}\, * \d {4}/
@@ -267,7 +276,7 @@ def check_disclosure_date
267
276
end
268
277
269
278
def check_title_casing
270
- if @source =~ /'Name'[[:space:]]*=>[[:space:]]*['| "](.+)['| "],*$/
279
+ if @source =~ /'Name'[[:space:]]*=>[[:space:]]*['"](.+)['"],*$/
271
280
words = $1. split
272
281
words . each do |word |
273
282
if %w{ and or the for to in of as with a an } . include? ( word )
0 commit comments