Class: Brakeman::CheckSessionSettings
- Inherits:
-
BaseCheck
- Object
- SexpProcessor
- BaseCheck
- Brakeman::CheckSessionSettings
- Defined in:
- lib/brakeman/checks/check_session_settings.rb
Overview
Checks for session key length and http_only settings
Constant Summary
Constants inherited from BaseCheck
Constants included from Util
Util::ALL_PARAMETERS, Util::COOKIES, Util::PARAMETERS, Util::PATH_PARAMETERS, Util::QUERY_PARAMETERS, Util::REQUEST_ENV, Util::REQUEST_PARAMETERS, Util::REQUEST_PARAMS, Util::SESSION
Constants inherited from SexpProcessor
Instance Attribute Summary
Attributes inherited from BaseCheck
Attributes inherited from SexpProcessor
Instance Method Summary collapse
-
#initialize(*args) ⇒ CheckSessionSettings
constructor
A new instance of CheckSessionSettings.
-
#process_attrasgn(exp) ⇒ Object
Looks for ActionController::Base.session = { … } in Rails 2.x apps.
-
#process_call(exp) ⇒ Object
Looks for Rails3::Application.config.session_store :cookie_store, { … } in Rails 3.x apps.
- #run_check ⇒ Object
Methods inherited from BaseCheck
#add_result, #process_cookies, #process_default, #process_if, #process_params
Methods included from Util
#array?, #call?, #camelize, #contains_class?, #context_for, #cookies?, #false?, #file_by_name, #file_for, #hash?, #hash_access, #hash_insert, #hash_iterate, #integer?, #node_type?, #number?, #params?, #pluralize, #regexp?, #request_env?, #request_value?, #result?, #set_env_defaults, #sexp?, #string?, #symbol?, #table_to_csv, #true?, #truncate_table, #underscore
Methods included from ProcessorHelper
#class_name, #process_all, #process_module
Methods inherited from SexpProcessor
#error_handler, #in_context, #process, #process_dummy, #scope
Constructor Details
#initialize(*args) ⇒ CheckSessionSettings
Returns a new instance of CheckSessionSettings.
9 10 11 12 13 14 15 16 17 |
# File 'lib/brakeman/checks/check_session_settings.rb', line 9 def initialize *args super if tracker.[:rails3] @session_settings = Sexp.new(:call, Sexp.new(:colon2, Sexp.new(:const, :Rails3), :Application), :config, Sexp.new(:arglist)) else @session_settings = Sexp.new(:colon2, Sexp.new(:const, :ActionController), :Base) end end |
Instance Method Details
#process_attrasgn(exp) ⇒ Object
Looks for ActionController::Base.session = { … } in Rails 2.x apps
33 34 35 36 37 38 39 |
# File 'lib/brakeman/checks/check_session_settings.rb', line 33 def process_attrasgn exp if not tracker.[:rails3] and exp.target == @session_settings and exp.method == :session= check_for_issues exp.first_arg, "#{tracker.[:app_path]}/config/initializers/session_store.rb" end exp end |
#process_call(exp) ⇒ Object
Looks for Rails3::Application.config.session_store :cookie_store, { … } in Rails 3.x apps
43 44 45 46 47 48 49 |
# File 'lib/brakeman/checks/check_session_settings.rb', line 43 def process_call exp if tracker.[:rails3] and exp.target == @session_settings and exp.method == :session_store check_for_issues exp.args.second, "#{tracker.[:app_path]}/config/initializers/session_store.rb" end exp end |
#run_check ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/brakeman/checks/check_session_settings.rb', line 19 def run_check settings = tracker.config[:rails] and tracker.config[:rails][:action_controller] and tracker.config[:rails][:action_controller][:session] check_for_issues settings, "#{tracker.[:app_path]}/config/environment.rb" if tracker.initializers["session_store.rb"] process tracker.initializers["session_store.rb"] end end |