Class: Simplabs::Excellent::Checks::Rails::SessionHashInViewCheck

Inherits:
Base
  • Object
show all
Defined in:
lib/simplabs/excellent/checks/rails/session_hash_in_view_check.rb

Overview

This check reports views (and partials) that access the session hash. Accessing the session hash directly in views can result in security problems if the value is printed to the HTML output and in general is a bad habit because the controller, which is actually the part of the application that is responsible for dealing with session data, is circumvented.

Applies to

  • partials and regular views

Instance Attribute Summary

Attributes inherited from Base

#interesting_files, #interesting_nodes, #warnings

Instance Method Summary collapse

Methods inherited from Base

#add_warning, #evaluate_node, #warnings_for

Constructor Details

#initializeSessionHashInViewCheck

:nodoc:



20
21
22
23
24
# File 'lib/simplabs/excellent/checks/rails/session_hash_in_view_check.rb', line 20

def initialize #:nodoc:
  super
  @interesting_nodes = [:call]
  @interesting_files = [/^.*\.(erb|rhtml)$/]
end

Instance Method Details

#evaluate(context) ⇒ Object

:nodoc:



26
27
28
# File 'lib/simplabs/excellent/checks/rails/session_hash_in_view_check.rb', line 26

def evaluate(context) #:nodoc:
  add_warning(context, 'Session hash used in view.') if (context.full_name == 'session')
end