Ruby on Rails Static Analysis Security Tool

Brakeman with Rake

Running Brakeman via Rake is discouraged because it loads the entire Rails application. This is unnecessary and can cause strange behavior.


Here is a simple Rake task to run Brakeman. It can be added to your Rakefile or in the tasks/ directory.

namespace :brakeman do

  desc "Run Brakeman"
  task :run, :output_files do |t, args|
    require 'brakeman'

    files = args[:output_files].split(' ') if args[:output_files] :app_path => ".", :output_files => files, :print_report => true

This task will run Brakeman with no options. If given an output file, it will save the report in that file. Otherwise, it will print the report out to the console.

To use this task:

rake brakeman:run


rake brakeman:run[report.html]

This task can easily be customized. See Brakeman as a Library for more information.

More documentation