@@ -62,7 +62,7 @@ def initialize(source_file)
62
62
# @return status [Integer] Returns WARNINGS unless we already have an
63
63
# error.
64
64
def warn ( txt , line = 0 ) line_msg = ( line >0 ) ? ":#{ line } " : ''
65
- puts "#{ @full_filepath } #{ line_msg } - [#{ 'WARNING' . yellow } ] #{ txt } "
65
+ puts "#{ @full_filepath } #{ line_msg } - [#{ 'WARNING' . yellow } ] #{ cleanup_text ( txt ) } "
66
66
@status == ERRORS ? @status = ERRORS : @status = WARNINGS
67
67
end
68
68
@@ -74,14 +74,14 @@ def warn(txt, line=0) line_msg = (line>0) ? ":#{line}" : ''
74
74
# @return status [Integer] Returns ERRORS
75
75
def error ( txt , line = 0 )
76
76
line_msg = ( line >0 ) ? ":#{ line } " : ''
77
- puts "#{ @full_filepath } #{ line_msg } - [#{ 'ERROR' . red } ] #{ txt } "
77
+ puts "#{ @full_filepath } #{ line_msg } - [#{ 'ERROR' . red } ] #{ cleanup_text ( txt ) } "
78
78
@status = ERRORS
79
79
end
80
80
81
81
# Currently unused, but some day msftidy will fix errors for you.
82
82
def fixed ( txt , line = 0 )
83
83
line_msg = ( line >0 ) ? ":#{ line } " : ''
84
- puts "#{ @full_filepath } #{ line_msg } - [#{ 'FIXED' . green } ] #{ txt } "
84
+ puts "#{ @full_filepath } #{ line_msg } - [#{ 'FIXED' . green } ] #{ cleanup_text ( txt ) } "
85
85
end
86
86
87
87
@@ -463,7 +463,7 @@ def check_lines
463
463
464
464
# do not change datastore in code
465
465
if ln =~ /(?<!\. )datastore\[ ["'][^"']+["']\] \s *=(?![=~>])/
466
- error ( "datastore is modified in code: #{ ln . inspect } " , idx )
466
+ error ( "datastore is modified in code: #{ ln } " , idx )
467
467
end
468
468
}
469
469
end
@@ -475,6 +475,15 @@ def check_vuln_codes
475
475
end
476
476
end
477
477
478
+ def check_vars_get
479
+ test = @source . scan ( /send_request_(?:cgi|raw)\s *\( \s *\{ \s *['"]uri['"]\s *=>\s *[^=\} ]*?\? [^,\} ]+/im )
480
+ unless test . empty?
481
+ test . each { |item |
482
+ warn ( "Please use vars_get in send_request_cgi and send_request_raw: #{ item } " )
483
+ }
484
+ end
485
+ end
486
+
478
487
private
479
488
480
489
def load_file ( file )
@@ -484,6 +493,13 @@ def load_file(file)
484
493
f . close
485
494
return buf
486
495
end
496
+
497
+ def cleanup_text ( txt )
498
+ # remove line breaks
499
+ txt = txt . gsub ( /[\r \n ]/ , ' ' )
500
+ # replace multiple spaces by one space
501
+ txt . gsub ( /\s {2,}/ , ' ' )
502
+ end
487
503
end
488
504
489
505
#
@@ -511,6 +527,7 @@ def run_checks(full_filepath)
511
527
tidy . check_snake_case_filename
512
528
tidy . check_comment_splat
513
529
tidy . check_vuln_codes
530
+ tidy . check_vars_get
514
531
return tidy
515
532
end
516
533
0 commit comments