File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -20,9 +20,7 @@ def initialize tracker
2020
2121 def default_protect_from_forgery?
2222 if version_between? "5.2.0.beta1" , "9.9.9"
23- if @rails . dig ( :action_controller , :default_protect_from_forgery ) == Sexp . new ( :false )
24- return false
25- else
23+ if @rails . dig ( :action_controller , :default_protect_from_forgery ) == Sexp . new ( :true )
2624 return true
2725 end
2826 end
Original file line number Diff line number Diff line change 1+ require_relative '../test'
2+ require 'brakeman/rescanner'
3+
4+ class Rails52CSRFTest < Minitest ::Test
5+ include BrakemanTester ::RescanTestHelper
6+ include BrakemanTester ::FindWarning
7+
8+ def report
9+ @report
10+ end
11+
12+ def test_csrf_with_no_load_defaults
13+ tracker = nil
14+
15+ # Terribly abusing the rescan functionality here.
16+ # Actually don't want the rescan, just want to run a regular scan
17+ # because we don't have the capability to rescan with on config changes
18+ # like this and I don't feel like building it right now.
19+ before_rescan_of [ 'config/application.rb' ] , 'rails5.2' do |app_dir |
20+ replace 'config/application.rb' , 'config.load_defaults 5.2' , ''
21+ tracker = Brakeman . run ( app_path : app_dir , parallel_checks : false )
22+ end
23+
24+ @report = tracker . report . to_hash
25+
26+ assert_warning check_name : "ForgerySetting" ,
27+ type : :controller ,
28+ warning_code : 7 ,
29+ fingerprint : "6f5239fb87c64764d0c209014deb5cf504c2c10ee424bd33590f0a4f22e01d8f" ,
30+ warning_type : "Cross-Site Request Forgery" ,
31+ line : 1 ,
32+ message : /^`protect_from_forgery`\ should\ be\ called\ / ,
33+ confidence : 0 ,
34+ relative_path : "app/controllers/application_controller.rb" ,
35+ code : nil ,
36+ user_input : nil
37+ end
38+ end
You can’t perform that action at this time.
0 commit comments