Class: Brakeman::CheckDetailedExceptions
- Inherits:
-
BaseCheck
- Object
- BaseCheck
- Brakeman::CheckDetailedExceptions
- Defined in:
- lib/brakeman/checks/check_detailed_exceptions.rb
Overview
Check for detailed exceptions enabled for production
Constant Summary collapse
- LOCAL_REQUEST =
s(:call, s(:call, nil, :request), :local?)
Instance Method Summary collapse
- #check_detailed_exceptions ⇒ Object
- #check_local_request_config ⇒ Object
- #run_check ⇒ Object
- #safe?(body) ⇒ Boolean
Instance Method Details
#check_detailed_exceptions ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/brakeman/checks/check_detailed_exceptions.rb', line 27 def check_detailed_exceptions tracker.controllers.each do |_name, controller| controller.methods_public.each do |method_name, definition| src = definition.src body = src.body.last next unless body if method_name == :show_detailed_exceptions? and not safe? body if true? body confidence = :high else confidence = :medium end warn :warning_type => "Information Disclosure", :warning_code => :detailed_exceptions, :message => msg("Detailed exceptions may be enabled in ", msg_code("show_detailed_exceptions?")), :confidence => confidence, :code => src, :file => definition[:file], :cwe_id => [200] end end end end |
#check_local_request_config ⇒ Object
16 17 18 19 20 21 22 23 24 25 |
# File 'lib/brakeman/checks/check_detailed_exceptions.rb', line 16 def check_local_request_config if true? tracker.config.rails[:consider_all_requests_local] warn :warning_type => "Information Disclosure", :warning_code => :local_request_config, :message => "Detailed exceptions are enabled in production", :confidence => :high, :file => "config/environments/production.rb", :cwe_id => [200] end end |
#run_check ⇒ Object
11 12 13 14 |
# File 'lib/brakeman/checks/check_detailed_exceptions.rb', line 11 def run_check check_local_request_config check_detailed_exceptions end |
#safe?(body) ⇒ Boolean
53 54 55 56 |
# File 'lib/brakeman/checks/check_detailed_exceptions.rb', line 53 def safe? body false? body or body == LOCAL_REQUEST end |