@@ -64,7 +64,7 @@ def initialize(source_file)
64
64
# @return status [Integer] Returns WARNINGS unless we already have an
65
65
# error.
66
66
def warn ( txt , line = 0 ) line_msg = ( line >0 ) ? ":#{ line } " : ''
67
- puts "#{ @full_filepath } #{ line_msg } - [#{ 'WARNING' . yellow } ] #{ txt } "
67
+ puts "#{ @full_filepath } #{ line_msg } - [#{ 'WARNING' . yellow } ] #{ cleanup_text ( txt ) } "
68
68
@status == ERRORS ? @status = ERRORS : @status = WARNINGS
69
69
end
70
70
@@ -76,14 +76,14 @@ def warn(txt, line=0) line_msg = (line>0) ? ":#{line}" : ''
76
76
# @return status [Integer] Returns ERRORS
77
77
def error ( txt , line = 0 )
78
78
line_msg = ( line >0 ) ? ":#{ line } " : ''
79
- puts "#{ @full_filepath } #{ line_msg } - [#{ 'ERROR' . red } ] #{ txt } "
79
+ puts "#{ @full_filepath } #{ line_msg } - [#{ 'ERROR' . red } ] #{ cleanup_text ( txt ) } "
80
80
@status = ERRORS
81
81
end
82
82
83
83
# Currently unused, but some day msftidy will fix errors for you.
84
84
def fixed ( txt , line = 0 )
85
85
line_msg = ( line >0 ) ? ":#{ line } " : ''
86
- puts "#{ @full_filepath } #{ line_msg } - [#{ 'FIXED' . green } ] #{ txt } "
86
+ puts "#{ @full_filepath } #{ line_msg } - [#{ 'FIXED' . green } ] #{ cleanup_text ( txt ) } "
87
87
end
88
88
89
89
@@ -469,7 +469,7 @@ def check_lines
469
469
470
470
# do not change datastore in code
471
471
if ln =~ /(?<!\. )datastore\[ ["'][^"']+["']\] \s *=(?![=~>])/
472
- error ( "datastore is modified in code: #{ ln . inspect } " , idx )
472
+ error ( "datastore is modified in code: #{ ln } " , idx )
473
473
end
474
474
}
475
475
end
@@ -481,6 +481,15 @@ def check_vuln_codes
481
481
end
482
482
end
483
483
484
+ def check_vars_get
485
+ test = @source . scan ( /send_request_(?:cgi|raw)\s *\( \s *\{ \s *['"]uri['"]\s *=>\s *[^=\} ]*?\? [^,\} ]+/im )
486
+ unless test . empty?
487
+ test . each { |item |
488
+ warn ( "Please use vars_get in send_request_cgi and send_request_raw: #{ item } " )
489
+ }
490
+ end
491
+ end
492
+
484
493
private
485
494
486
495
def load_file ( file )
@@ -490,6 +499,13 @@ def load_file(file)
490
499
f . close
491
500
return buf
492
501
end
502
+
503
+ def cleanup_text ( txt )
504
+ # remove line breaks
505
+ txt = txt . gsub ( /[\r \n ]/ , ' ' )
506
+ # replace multiple spaces by one space
507
+ txt . gsub ( /\s {2,}/ , ' ' )
508
+ end
493
509
end
494
510
495
511
#
@@ -517,6 +533,7 @@ def run_checks(full_filepath)
517
533
tidy . check_snake_case_filename
518
534
tidy . check_comment_splat
519
535
tidy . check_vuln_codes
536
+ tidy . check_vars_get
520
537
return tidy
521
538
end
522
539
0 commit comments