brakeman 4.1.1 → 4.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGES.md +13 -0
- data/bundle/load.rb +3 -3
- data/bundle/ruby/2.3.0/gems/{ruby2ruby-2.4.0 → ruby2ruby-2.4.1}/History.rdoc +7 -0
- data/bundle/ruby/2.3.0/gems/{ruby2ruby-2.4.0 → ruby2ruby-2.4.1}/Manifest.txt +0 -0
- data/bundle/ruby/2.3.0/gems/{ruby2ruby-2.4.0 → ruby2ruby-2.4.1}/README.rdoc +0 -0
- data/bundle/ruby/2.3.0/gems/{ruby2ruby-2.4.0 → ruby2ruby-2.4.1}/Rakefile +0 -0
- data/bundle/ruby/2.3.0/gems/{ruby2ruby-2.4.0 → ruby2ruby-2.4.1}/bin/r2r_show +0 -0
- data/bundle/ruby/2.3.0/gems/{ruby2ruby-2.4.0 → ruby2ruby-2.4.1}/lib/ruby2ruby.rb +43 -2
- data/bundle/ruby/2.3.0/gems/{ruby2ruby-2.4.0 → ruby2ruby-2.4.1}/test/test_ruby2ruby.rb +5 -4
- data/bundle/ruby/2.3.0/gems/{ruby_parser-3.10.1 → ruby_parser-3.11.0}/History.rdoc +12 -0
- data/bundle/ruby/2.3.0/gems/{ruby_parser-3.10.1 → ruby_parser-3.11.0}/Manifest.txt +2 -0
- data/bundle/ruby/2.3.0/gems/{ruby_parser-3.10.1 → ruby_parser-3.11.0}/README.rdoc +5 -1
- data/bundle/ruby/2.3.0/gems/{ruby_parser-3.10.1 → ruby_parser-3.11.0}/Rakefile +1 -1
- data/bundle/ruby/2.3.0/gems/{ruby_parser-3.10.1 → ruby_parser-3.11.0}/bin/ruby_parse +0 -0
- data/bundle/ruby/2.3.0/gems/{ruby_parser-3.10.1 → ruby_parser-3.11.0}/bin/ruby_parse_extract_error +0 -0
- data/bundle/ruby/2.3.0/gems/{ruby_parser-3.10.1 → ruby_parser-3.11.0}/compare/normalize.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{ruby_parser-3.10.1 → ruby_parser-3.11.0}/lib/rp_extensions.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{ruby_parser-3.10.1 → ruby_parser-3.11.0}/lib/rp_stringscanner.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{ruby_parser-3.10.1 → ruby_parser-3.11.0}/lib/ruby18_parser.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{ruby_parser-3.10.1 → ruby_parser-3.11.0}/lib/ruby18_parser.y +0 -0
- data/bundle/ruby/2.3.0/gems/{ruby_parser-3.10.1 → ruby_parser-3.11.0}/lib/ruby19_parser.rb +1751 -1745
- data/bundle/ruby/2.3.0/gems/{ruby_parser-3.10.1 → ruby_parser-3.11.0}/lib/ruby19_parser.y +2 -2
- data/bundle/ruby/2.3.0/gems/{ruby_parser-3.10.1 → ruby_parser-3.11.0}/lib/ruby20_parser.rb +1717 -1717
- data/bundle/ruby/2.3.0/gems/{ruby_parser-3.10.1 → ruby_parser-3.11.0}/lib/ruby20_parser.y +2 -2
- data/bundle/ruby/2.3.0/gems/{ruby_parser-3.10.1 → ruby_parser-3.11.0}/lib/ruby21_parser.rb +1824 -1819
- data/bundle/ruby/2.3.0/gems/{ruby_parser-3.10.1 → ruby_parser-3.11.0}/lib/ruby21_parser.y +2 -2
- data/bundle/ruby/2.3.0/gems/{ruby_parser-3.10.1 → ruby_parser-3.11.0}/lib/ruby22_parser.rb +1838 -1846
- data/bundle/ruby/2.3.0/gems/{ruby_parser-3.10.1 → ruby_parser-3.11.0}/lib/ruby22_parser.y +2 -2
- data/bundle/ruby/2.3.0/gems/{ruby_parser-3.10.1 → ruby_parser-3.11.0}/lib/ruby23_parser.rb +1836 -1837
- data/bundle/ruby/2.3.0/gems/{ruby_parser-3.10.1 → ruby_parser-3.11.0}/lib/ruby23_parser.y +2 -2
- data/bundle/ruby/2.3.0/gems/{ruby_parser-3.10.1 → ruby_parser-3.11.0}/lib/ruby24_parser.rb +1836 -1837
- data/bundle/ruby/2.3.0/gems/{ruby_parser-3.10.1 → ruby_parser-3.11.0}/lib/ruby24_parser.y +2 -2
- data/bundle/ruby/2.3.0/gems/ruby_parser-3.11.0/lib/ruby25_parser.rb +6818 -0
- data/bundle/ruby/2.3.0/gems/ruby_parser-3.11.0/lib/ruby25_parser.y +2378 -0
- data/bundle/ruby/2.3.0/gems/{ruby_parser-3.10.1 → ruby_parser-3.11.0}/lib/ruby_lexer.rb +8 -2
- data/bundle/ruby/2.3.0/gems/{ruby_parser-3.10.1 → ruby_parser-3.11.0}/lib/ruby_lexer.rex +0 -0
- data/bundle/ruby/2.3.0/gems/{ruby_parser-3.10.1 → ruby_parser-3.11.0}/lib/ruby_lexer.rex.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{ruby_parser-3.10.1 → ruby_parser-3.11.0}/lib/ruby_parser.rb +2 -0
- data/bundle/ruby/2.3.0/gems/{ruby_parser-3.10.1 → ruby_parser-3.11.0}/lib/ruby_parser.yy +4 -2
- data/bundle/ruby/2.3.0/gems/{ruby_parser-3.10.1 → ruby_parser-3.11.0}/lib/ruby_parser_extras.rb +2 -7
- data/bundle/ruby/2.3.0/gems/{ruby_parser-3.10.1 → ruby_parser-3.11.0}/test/test_ruby_lexer.rb +22 -0
- data/bundle/ruby/2.3.0/gems/{ruby_parser-3.10.1 → ruby_parser-3.11.0}/test/test_ruby_parser.rb +39 -0
- data/bundle/ruby/2.3.0/gems/{ruby_parser-3.10.1 → ruby_parser-3.11.0}/test/test_ruby_parser_extras.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{sexp_processor-4.10.0/History.txt → sexp_processor-4.10.1/History.rdoc} +6 -0
- data/bundle/ruby/2.3.0/gems/{sexp_processor-4.10.0 → sexp_processor-4.10.1}/Manifest.txt +2 -2
- data/bundle/ruby/2.3.0/gems/{sexp_processor-4.10.0/README.txt → sexp_processor-4.10.1/README.rdoc} +0 -0
- data/bundle/ruby/2.3.0/gems/{sexp_processor-4.10.0 → sexp_processor-4.10.1}/Rakefile +1 -0
- data/bundle/ruby/2.3.0/gems/{sexp_processor-4.10.0 → sexp_processor-4.10.1}/lib/composite_sexp_processor.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{sexp_processor-4.10.0 → sexp_processor-4.10.1}/lib/pt_testcase.rb +16 -9
- data/bundle/ruby/2.3.0/gems/{sexp_processor-4.10.0 → sexp_processor-4.10.1}/lib/sexp.rb +1 -2
- data/bundle/ruby/2.3.0/gems/{sexp_processor-4.10.0 → sexp_processor-4.10.1}/lib/sexp_processor.rb +1 -1
- data/bundle/ruby/2.3.0/gems/{sexp_processor-4.10.0 → sexp_processor-4.10.1}/lib/strict_sexp.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{sexp_processor-4.10.0 → sexp_processor-4.10.1}/lib/unique.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{sexp_processor-4.10.0 → sexp_processor-4.10.1}/test/test_composite_sexp_processor.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{sexp_processor-4.10.0 → sexp_processor-4.10.1}/test/test_environment.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{sexp_processor-4.10.0 → sexp_processor-4.10.1}/test/test_sexp.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{sexp_processor-4.10.0 → sexp_processor-4.10.1}/test/test_sexp_processor.rb +0 -0
- data/lib/brakeman/app_tree.rb +1 -1
- data/lib/brakeman/checks/base_check.rb +2 -6
- data/lib/brakeman/checks/check_execute.rb +21 -3
- data/lib/brakeman/checks/check_redirect.rb +3 -1
- data/lib/brakeman/checks/check_sql.rb +2 -2
- data/lib/brakeman/checks/check_symbol_dos.rb +8 -0
- data/lib/brakeman/checks/check_unscoped_find.rb +17 -1
- data/lib/brakeman/processors/alias_processor.rb +5 -2
- data/lib/brakeman/processors/base_processor.rb +1 -5
- data/lib/brakeman/processors/erb_template_processor.rb +1 -1
- data/lib/brakeman/processors/library_processor.rb +9 -1
- data/lib/brakeman/version.rb +1 -1
- data/lib/ruby_parser/bm_sexp.rb +4 -0
- metadata +58 -56
@@ -548,7 +548,7 @@ class RubyLexer
|
|
548
548
|
self.lineno += matched.lines.to_a.size if scan(/\n+/)
|
549
549
|
|
550
550
|
return if in_lex_state?(:expr_beg, :expr_value, :expr_class,
|
551
|
-
:expr_fname, :expr_dot
|
551
|
+
:expr_fname, :expr_dot)
|
552
552
|
|
553
553
|
if scan(/([\ \t\r\f\v]*)(\.|&)/) then
|
554
554
|
self.space_seen = true unless ss[1].empty?
|
@@ -1042,7 +1042,13 @@ class RubyLexer
|
|
1042
1042
|
when scan(/\\[McCx]/) then
|
1043
1043
|
rb_compile_error "Invalid escape character syntax"
|
1044
1044
|
when scan(/\\(.)/m) then
|
1045
|
-
|
1045
|
+
chr = ss[1]
|
1046
|
+
prev = self.string_buffer.last
|
1047
|
+
if term == chr && prev && prev.end_with?("(?") then
|
1048
|
+
self.string_buffer << chr
|
1049
|
+
else
|
1050
|
+
self.string_buffer << matched
|
1051
|
+
end
|
1046
1052
|
else
|
1047
1053
|
rb_compile_error "Invalid escape character syntax"
|
1048
1054
|
end
|
File without changes
|
File without changes
|
@@ -72,10 +72,12 @@ require "ruby21_parser"
|
|
72
72
|
require "ruby22_parser"
|
73
73
|
require "ruby23_parser"
|
74
74
|
require "ruby24_parser"
|
75
|
+
require "ruby25_parser"
|
75
76
|
|
76
77
|
class RubyParser # HACK
|
77
78
|
VERSIONS.clear # also a HACK caused by racc namespace issues
|
78
79
|
|
80
|
+
class V25 < ::Ruby25Parser; end
|
79
81
|
class V24 < ::Ruby24Parser; end
|
80
82
|
class V23 < ::Ruby23Parser; end
|
81
83
|
class V22 < ::Ruby22Parser; end
|
@@ -10,6 +10,8 @@ class Ruby22Parser
|
|
10
10
|
class Ruby23Parser
|
11
11
|
#elif V == 24
|
12
12
|
class Ruby24Parser
|
13
|
+
#elif V == 25
|
14
|
+
class Ruby25Parser
|
13
15
|
#else
|
14
16
|
fail "version not specified or supported on code generation"
|
15
17
|
#endif
|
@@ -2418,9 +2420,9 @@ keyword_variable: kNIL { result = s(:nil) }
|
|
2418
2420
|
{
|
2419
2421
|
result = s(:array, val[0], val[2])
|
2420
2422
|
}
|
2421
|
-
| tLABEL arg_value
|
2423
|
+
| tLABEL opt_nl arg_value
|
2422
2424
|
{
|
2423
|
-
result = s(:array, s(:lit, val[0][0].to_sym), val
|
2425
|
+
result = s(:array, s(:lit, val[0][0].to_sym), val.last)
|
2424
2426
|
}
|
2425
2427
|
#if V >= 22
|
2426
2428
|
| tSTRING_BEG string_contents tLABEL_END arg_value
|
data/bundle/ruby/2.3.0/gems/{ruby_parser-3.10.1 → ruby_parser-3.11.0}/lib/ruby_parser_extras.rb
RENAMED
@@ -7,7 +7,7 @@ require "rp_extensions"
|
|
7
7
|
require "rp_stringscanner"
|
8
8
|
|
9
9
|
module RubyParserStuff
|
10
|
-
VERSION = "3.
|
10
|
+
VERSION = "3.11.0"
|
11
11
|
|
12
12
|
attr_accessor :lexer, :in_def, :in_single, :file
|
13
13
|
attr_reader :env, :comments
|
@@ -437,12 +437,7 @@ module RubyParserStuff
|
|
437
437
|
def new_aref val
|
438
438
|
val[2] ||= s(:arglist)
|
439
439
|
val[2].sexp_type = :arglist if val[2].sexp_type == :array # REFACTOR
|
440
|
-
|
441
|
-
result = new_call nil, :"[]", val[2]
|
442
|
-
else
|
443
|
-
result = new_call val[0], :"[]", val[2]
|
444
|
-
end
|
445
|
-
result
|
440
|
+
new_call val[0], :"[]", val[2]
|
446
441
|
end
|
447
442
|
|
448
443
|
def new_body val
|
data/bundle/ruby/2.3.0/gems/{ruby_parser-3.10.1 → ruby_parser-3.11.0}/test/test_ruby_lexer.rb
RENAMED
@@ -2053,6 +2053,14 @@ class TestRubyLexer < Minitest::Test
|
|
2053
2053
|
:tREGEXP_END, "", :expr_end)
|
2054
2054
|
end
|
2055
2055
|
|
2056
|
+
def test_yylex_regexp_escaped_delim
|
2057
|
+
assert_lex3("%r!blah(?\\!blah)!",
|
2058
|
+
nil,
|
2059
|
+
:tREGEXP_BEG, "%r\000", :expr_beg,
|
2060
|
+
:tSTRING_CONTENT, "blah(?!blah)", :expr_beg,
|
2061
|
+
:tREGEXP_END, "", :expr_end)
|
2062
|
+
end
|
2063
|
+
|
2056
2064
|
def test_yylex_regexp_escape_backslash_terminator_meta1
|
2057
2065
|
assert_lex3("%r{blah\\}blah}",
|
2058
2066
|
nil,
|
@@ -2797,6 +2805,20 @@ class TestRubyLexer < Minitest::Test
|
|
2797
2805
|
:tRCURLY, "}", :expr_endarg, 0, 0)
|
2798
2806
|
end
|
2799
2807
|
|
2808
|
+
def test_yylex_required_kwarg_no_value_22
|
2809
|
+
setup_lexer_class RubyParser::V22
|
2810
|
+
|
2811
|
+
assert_lex3("def foo a:, b:\nend",
|
2812
|
+
nil,
|
2813
|
+
:kDEF, "def", :expr_fname,
|
2814
|
+
:tIDENTIFIER, "foo", :expr_endfn,
|
2815
|
+
:tLABEL, "a", :expr_labelarg,
|
2816
|
+
:tCOMMA, ",", :expr_beg,
|
2817
|
+
:tLABEL, "b", :expr_labelarg,
|
2818
|
+
:tNL, nil, :expr_beg,
|
2819
|
+
:kEND, "end", :expr_end)
|
2820
|
+
end
|
2821
|
+
|
2800
2822
|
def test_ruby21_rational_literal
|
2801
2823
|
setup_lexer_class RubyParser::V21
|
2802
2824
|
|
data/bundle/ruby/2.3.0/gems/{ruby_parser-3.10.1 → ruby_parser-3.11.0}/test/test_ruby_parser.rb
RENAMED
@@ -171,6 +171,13 @@ module TestRubyParserShared
|
|
171
171
|
assert_parse rb, pt
|
172
172
|
end
|
173
173
|
|
174
|
+
def test_call_self_brackets
|
175
|
+
rb = "self[1]"
|
176
|
+
pt = s(:call, s(:self), :[], s(:lit, 1))
|
177
|
+
|
178
|
+
assert_parse rb, pt
|
179
|
+
end
|
180
|
+
|
174
181
|
def test_dasgn_icky2
|
175
182
|
rb = "a do\n v = nil\n begin\n yield\n rescue Exception => v\n break\n end\nend"
|
176
183
|
pt = s(:iter,
|
@@ -3419,6 +3426,17 @@ module TestRubyParserShared23Plus
|
|
3419
3426
|
assert_parse rb, pt
|
3420
3427
|
end
|
3421
3428
|
|
3429
|
+
def test_required_kwarg_no_value
|
3430
|
+
rb = "def x a:, b:\nend"
|
3431
|
+
pt = s(:defn, :x,
|
3432
|
+
s(:args,
|
3433
|
+
s(:kwarg, :a),
|
3434
|
+
s(:kwarg, :b)),
|
3435
|
+
s(:nil))
|
3436
|
+
|
3437
|
+
assert_parse rb, pt
|
3438
|
+
end
|
3439
|
+
|
3422
3440
|
def test_slashy_newlines_within_string
|
3423
3441
|
rb = %(puts "hello\\
|
3424
3442
|
my\\
|
@@ -3443,6 +3461,10 @@ module TestRubyParserShared24Plus
|
|
3443
3461
|
# ...version specific tests to go here...
|
3444
3462
|
end
|
3445
3463
|
|
3464
|
+
module TestRubyParserShared25Plus
|
3465
|
+
# ...version specific tests to go here...
|
3466
|
+
end
|
3467
|
+
|
3446
3468
|
class TestRubyParser < Minitest::Test
|
3447
3469
|
def test_cls_version
|
3448
3470
|
assert_equal 18, RubyParser::V18.version
|
@@ -3729,6 +3751,23 @@ class TestRubyParserV24 < RubyParserTestCase
|
|
3729
3751
|
end
|
3730
3752
|
end
|
3731
3753
|
|
3754
|
+
class TestRubyParserV25 < RubyParserTestCase
|
3755
|
+
include TestRubyParserShared
|
3756
|
+
include TestRubyParserShared19Plus
|
3757
|
+
include TestRubyParserShared20Plus
|
3758
|
+
include TestRubyParserShared21Plus
|
3759
|
+
include TestRubyParserShared22Plus
|
3760
|
+
include TestRubyParserShared23Plus
|
3761
|
+
include TestRubyParserShared24Plus
|
3762
|
+
include TestRubyParserShared25Plus
|
3763
|
+
|
3764
|
+
def setup
|
3765
|
+
super
|
3766
|
+
|
3767
|
+
self.processor = RubyParser::V25.new
|
3768
|
+
end
|
3769
|
+
end
|
3770
|
+
|
3732
3771
|
RubyParser::VERSIONS.each do |klass|
|
3733
3772
|
v = klass.version
|
3734
3773
|
describe "block args arity #{v}" do
|
File without changes
|
data/bundle/ruby/2.3.0/gems/{sexp_processor-4.10.0/README.txt → sexp_processor-4.10.1/README.rdoc}
RENAMED
File without changes
|
File without changes
|
data/bundle/ruby/2.3.0/gems/{sexp_processor-4.10.0 → sexp_processor-4.10.1}/lib/pt_testcase.rb
RENAMED
@@ -77,7 +77,7 @@ class ParseTreeTestCase < Minitest::Test
|
|
77
77
|
end
|
78
78
|
|
79
79
|
def self.add_19tests name, hash
|
80
|
-
add_tests "#{name}
|
80
|
+
add_tests "#{name}__19_20_21_22_23_24_25", hash # HACK?
|
81
81
|
end
|
82
82
|
|
83
83
|
def self.add_19edgecases ruby, sexp, cases
|
@@ -102,7 +102,7 @@ class ParseTreeTestCase < Minitest::Test
|
|
102
102
|
testcases[verbose][klass] = testcases[nonverbose][klass]
|
103
103
|
end
|
104
104
|
|
105
|
-
VER_RE = "(1[89]|2[
|
105
|
+
VER_RE = "(1[89]|2[012345])"
|
106
106
|
|
107
107
|
def self.generate_test klass, node, data, input_name, output_name
|
108
108
|
klass.send :define_method, "test_#{node}" do
|
@@ -441,11 +441,13 @@ class ParseTreeTestCase < Minitest::Test
|
|
441
441
|
"Ruby" => "!a",
|
442
442
|
"ParseTree" => s(:call,
|
443
443
|
s(:call, nil, :a),
|
444
|
-
:"!")
|
444
|
+
:"!"),
|
445
|
+
"Ruby2Ruby" => "(not a)")
|
445
446
|
|
446
447
|
add_19tests("call_bang_empty",
|
447
448
|
"Ruby" => "! ()",
|
448
|
-
"ParseTree" => s(:call, s(:nil), :"!")
|
449
|
+
"ParseTree" => s(:call, s(:nil), :"!"),
|
450
|
+
"Ruby2Ruby" => "(not nil)")
|
449
451
|
|
450
452
|
add_19tests("call_fonz",
|
451
453
|
"Ruby" => "a.()",
|
@@ -459,7 +461,8 @@ class ParseTreeTestCase < Minitest::Test
|
|
459
461
|
|
460
462
|
add_19tests("call_not",
|
461
463
|
"Ruby" => "not (42)",
|
462
|
-
"ParseTree" => s(:call, s(:lit, 42), :"!")
|
464
|
+
"ParseTree" => s(:call, s(:lit, 42), :"!"),
|
465
|
+
"Ruby2Ruby" => "(not 42)")
|
463
466
|
|
464
467
|
# add_19tests("call_not_empty",
|
465
468
|
# "Ruby" => "not ()",
|
@@ -470,7 +473,8 @@ class ParseTreeTestCase < Minitest::Test
|
|
470
473
|
"ParseTree" => s(:call,
|
471
474
|
s(:call, nil, :a),
|
472
475
|
:"!=",
|
473
|
-
s(:call, nil, :b))
|
476
|
+
s(:call, nil, :b)),
|
477
|
+
"Ruby2Ruby" => "(a != b)")
|
474
478
|
|
475
479
|
add_19tests("call_splat_mid",
|
476
480
|
"Ruby" => "def f(a = nil, *b, c)\n # do nothing\nend",
|
@@ -589,15 +593,18 @@ class ParseTreeTestCase < Minitest::Test
|
|
589
593
|
|
590
594
|
add_19tests("str_question_control",
|
591
595
|
"Ruby" => '?\M-\C-a',
|
592
|
-
"ParseTree" => s(:str, "\x81")
|
596
|
+
"ParseTree" => s(:str, "\x81"),
|
597
|
+
"Ruby2Ruby" => "\"\\x81\"")
|
593
598
|
|
594
599
|
add_19tests("str_question_escape",
|
595
600
|
"Ruby" => '?\n',
|
596
|
-
"ParseTree" => s(:str, "\n")
|
601
|
+
"ParseTree" => s(:str, "\n"),
|
602
|
+
"Ruby2Ruby" => "\"\\n\"")
|
597
603
|
|
598
604
|
add_19tests("str_question_literal",
|
599
605
|
"Ruby" => "?a",
|
600
|
-
"ParseTree" => s(:str, "a")
|
606
|
+
"ParseTree" => s(:str, "a"),
|
607
|
+
"Ruby2Ruby" => '"a"')
|
601
608
|
|
602
609
|
add_19tests("unless_post_not",
|
603
610
|
"Ruby" => "a unless not b",
|
@@ -582,7 +582,6 @@ class Sexp #:nodoc:
|
|
582
582
|
#
|
583
583
|
# * For pattern creation, see factory methods: Sexp::_, Sexp::___, etc.
|
584
584
|
# * For matching returning truthy/falsey results, see Sexp#=~.
|
585
|
-
# * See Sexp#=~ for matching returning truthy/falsey results.
|
586
585
|
# * For case expressions, see Matcher#===.
|
587
586
|
# * For getting all subtree matches, see Sexp#/.
|
588
587
|
#
|
@@ -758,7 +757,7 @@ class Sexp #:nodoc:
|
|
758
757
|
# Converts +s+ into a stream of tokens and adds them to +tokens+.
|
759
758
|
|
760
759
|
def lex s
|
761
|
-
tokens.concat s.scan(%r%[()\[\]]|\"[^"]*\"|/[^/]*/|[\w-]+%)
|
760
|
+
tokens.concat s.scan(%r%[()\[\]]|\"[^"]*\"|/[^/]*/|[\w-]+%) # "
|
762
761
|
end
|
763
762
|
|
764
763
|
##
|
data/bundle/ruby/2.3.0/gems/{sexp_processor-4.10.0 → sexp_processor-4.10.1}/lib/strict_sexp.rb
RENAMED
File without changes
|
File without changes
|
File without changes
|
data/bundle/ruby/2.3.0/gems/{sexp_processor-4.10.0 → sexp_processor-4.10.1}/test/test_environment.rb
RENAMED
File without changes
|
data/bundle/ruby/2.3.0/gems/{sexp_processor-4.10.0 → sexp_processor-4.10.1}/test/test_sexp.rb
RENAMED
File without changes
|
File without changes
|
data/lib/brakeman/app_tree.rb
CHANGED
@@ -110,7 +110,7 @@ module Brakeman
|
|
110
110
|
end
|
111
111
|
|
112
112
|
def lib_paths
|
113
|
-
@lib_files ||= find_paths("lib").reject { |path| path.include? "/generators/" or path.include? "lib/tasks/" } +
|
113
|
+
@lib_files ||= find_paths("lib").reject { |path| path.include? "/generators/" or path.include? "lib/tasks/" or path.include? "lib/templates/" } +
|
114
114
|
find_additional_lib_paths +
|
115
115
|
find_helper_paths
|
116
116
|
end
|
@@ -62,12 +62,8 @@ class Brakeman::BaseCheck < Brakeman::SexpProcessor
|
|
62
62
|
#Default Sexp processing. Iterates over each value in the Sexp
|
63
63
|
#and processes them if they are also Sexps.
|
64
64
|
def process_default exp
|
65
|
-
exp.
|
66
|
-
if sexp? e
|
67
|
-
process e
|
68
|
-
else
|
69
|
-
e
|
70
|
-
end
|
65
|
+
exp.each do |e|
|
66
|
+
process e if sexp? e
|
71
67
|
end
|
72
68
|
|
73
69
|
exp
|
@@ -17,6 +17,10 @@ class Brakeman::CheckExecute < Brakeman::BaseCheck
|
|
17
17
|
s(:call, s(:const, :Rails), :root),
|
18
18
|
s(:call, s(:const, :Rails), :env)]
|
19
19
|
|
20
|
+
SHELL_ESCAPES = [:escape, :shellescape, :join]
|
21
|
+
|
22
|
+
SHELLWORDS = s(:const, :Shellwords)
|
23
|
+
|
20
24
|
#Check models, controllers, and views for command injection.
|
21
25
|
def run_check
|
22
26
|
Brakeman.debug "Finding system calls using ``"
|
@@ -127,15 +131,17 @@ class Brakeman::CheckExecute < Brakeman::BaseCheck
|
|
127
131
|
:confidence => confidence
|
128
132
|
end
|
129
133
|
|
134
|
+
# This method expects a :dstr or :evstr node
|
130
135
|
def dangerous? exp
|
131
136
|
exp.each_sexp do |e|
|
132
|
-
next if node_type? e, :lit, :str
|
133
|
-
next if SAFE_VALUES.include? e
|
134
|
-
|
135
137
|
if call? e and e.method == :to_s
|
136
138
|
e = e.target
|
137
139
|
end
|
138
140
|
|
141
|
+
next if node_type? e, :lit, :str
|
142
|
+
next if SAFE_VALUES.include? e
|
143
|
+
next if shell_escape? e
|
144
|
+
|
139
145
|
if node_type? e, :or, :evstr, :dstr
|
140
146
|
if res = dangerous?(e)
|
141
147
|
return res
|
@@ -161,4 +167,16 @@ class Brakeman::CheckExecute < Brakeman::BaseCheck
|
|
161
167
|
|
162
168
|
false
|
163
169
|
end
|
170
|
+
|
171
|
+
def shell_escape? exp
|
172
|
+
return false unless call? exp
|
173
|
+
|
174
|
+
if exp.target == SHELLWORDS and SHELL_ESCAPES.include? exp.method
|
175
|
+
true
|
176
|
+
elsif exp.method == :shelljoin
|
177
|
+
true
|
178
|
+
else
|
179
|
+
false
|
180
|
+
end
|
181
|
+
end
|
164
182
|
end
|
@@ -79,7 +79,9 @@ class Brakeman::CheckRedirect < Brakeman::BaseCheck
|
|
79
79
|
end
|
80
80
|
|
81
81
|
if res = has_immediate_model?(arg)
|
82
|
-
|
82
|
+
unless call? arg and arg.method.to_s =~ /_path/
|
83
|
+
return Match.new(immediate, res)
|
84
|
+
end
|
83
85
|
elsif call? arg
|
84
86
|
if request_value? arg
|
85
87
|
return Match.new(immediate, arg)
|
@@ -19,7 +19,7 @@ class Brakeman::CheckSQL < Brakeman::BaseCheck
|
|
19
19
|
@sql_targets = [:average, :calculate, :count, :count_by_sql, :delete_all, :destroy_all,
|
20
20
|
:find_by_sql, :maximum, :minimum, :pluck, :sum, :update_all]
|
21
21
|
@sql_targets.concat [:from, :group, :having, :joins, :lock, :order, :reorder, :where] if tracker.options[:rails3]
|
22
|
-
@sql_targets << :find_by << :find_by! if tracker.options[:rails4]
|
22
|
+
@sql_targets << :find_by << :find_by! << :not if tracker.options[:rails4]
|
23
23
|
|
24
24
|
if version_between?("2.0.0", "3.9.9") or tracker.config.rails_version.nil?
|
25
25
|
@sql_targets << :first << :last << :all
|
@@ -184,7 +184,7 @@ class Brakeman::CheckSQL < Brakeman::BaseCheck
|
|
184
184
|
else
|
185
185
|
check_find_arguments call.last_arg
|
186
186
|
end
|
187
|
-
when :where, :having, :find_by, :find_by
|
187
|
+
when :where, :having, :find_by, :find_by!, :not
|
188
188
|
check_query_arguments call.arglist
|
189
189
|
when :order, :group, :reorder
|
190
190
|
check_order_arguments call.arglist
|
@@ -33,8 +33,10 @@ class Brakeman::CheckSymbolDoS < Brakeman::BaseCheck
|
|
33
33
|
confidence = :medium
|
34
34
|
end
|
35
35
|
|
36
|
+
|
36
37
|
if confidence
|
37
38
|
return if safe_parameter? input.match
|
39
|
+
return if symbolizing_attributes? input
|
38
40
|
|
39
41
|
message = "Symbol conversion from unsafe string (#{friendly_type_of input})"
|
40
42
|
|
@@ -60,4 +62,10 @@ class Brakeman::CheckSymbolDoS < Brakeman::BaseCheck
|
|
60
62
|
false
|
61
63
|
end
|
62
64
|
end
|
65
|
+
|
66
|
+
def symbolizing_attributes? input
|
67
|
+
input.type == :model and
|
68
|
+
call? input.match and
|
69
|
+
input.match.method == :attributes
|
70
|
+
end
|
63
71
|
end
|