Sha256: c8e293e6398ebd6739602170e6075dd898301431ce9aba5b7c2d312994998491

Contents?: true

Size: 1.06 KB

Versions: 35

Compression:

Stored size: 1.06 KB

Contents

require 'checks/base_check'

#Checks if default routes are allowed in routes.rb
class CheckDefaultRoutes < BaseCheck
  Checks.add self

  #Checks for :allow_all_actions globally and for individual routes
  #if it is not enabled globally.
  def run_check
    if tracker.routes[:allow_all_actions]
      #Default routes are enabled globally
      warn :warning_type => "Default Routes", 
        :message => "All public methods in controllers are available as actions in routes.rb",
        :line => tracker.routes[:allow_all_actions].line, 
        :confidence => CONFIDENCE[:high],
        :file => "#{OPTIONS[:app_path]}/config/routes.rb"
    else #Report each controller separately
      tracker.routes.each do |name, actions|
        if actions == :allow_all_actions
          warn :controller => name,
            :warning_type => "Default Routes", 
            :message => "Any public method in #{name} can be used as an action.",
            :confidence => CONFIDENCE[:med],
            :file => "#{OPTIONS[:app_path]}/config/routes.rb"
        end
      end
    end
  end
end

Version data entries

35 entries across 35 versions & 2 rubygems

Version Path
brakeman-0.8.3 lib/checks/check_default_routes.rb
brakeman-0.8.2 lib/checks/check_default_routes.rb
brakeman-0.8.1 lib/checks/check_default_routes.rb
brakeman-0.8.0 lib/checks/check_default_routes.rb
brakeman-0.7.2 lib/checks/check_default_routes.rb
brakeman-0.7.1 lib/checks/check_default_routes.rb
brakeman-0.7.0 lib/checks/check_default_routes.rb
brakeman-0.6.1 lib/checks/check_default_routes.rb
brakeman-0.6.0 lib/checks/check_default_routes.rb
brakeman-min-0.5.2 lib/checks/check_default_routes.rb
brakeman-0.5.2 lib/checks/check_default_routes.rb
brakeman-min-0.5.1 lib/checks/check_default_routes.rb
brakeman-0.5.1 lib/checks/check_default_routes.rb
brakeman-min-0.5.0 lib/checks/check_default_routes.rb
brakeman-0.5.0 lib/checks/check_default_routes.rb
brakeman-0.4.1 lib/checks/check_default_routes.rb
brakeman-min-0.4.1 lib/checks/check_default_routes.rb
brakeman-min-0.4.0 lib/checks/check_default_routes.rb
brakeman-0.4.0 lib/checks/check_default_routes.rb
brakeman-min-0.3.2 lib/checks/check_default_routes.rb