Sha256: 7ca49e0a002d3cf5f9502e8a0bb2f9ddda36bae5d1788075e6dbe40e15ee5696

Contents?: true

Size: 1002 Bytes

Versions: 3

Compression:

Stored size: 1002 Bytes

Contents

require 'simplabs/excellent/checks/base'

module Simplabs

  module Excellent

    module Checks

      module Rails

        # 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
        class SessionHashInViewCheck < Base

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

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

        end

      end

    end

  end

end

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
simplabs-excellent-1.5.2 lib/simplabs/excellent/checks/rails/session_hash_in_view_check.rb
simplabs-excellent-1.5.3 lib/simplabs/excellent/checks/rails/session_hash_in_view_check.rb
excellent-1.5.4 lib/simplabs/excellent/checks/rails/session_hash_in_view_check.rb