Brakeman

Public
Brakeman detects security vulnerabilities in Ruby on Rails applications via static analysis.
Icons/chart bar
Used 75 times
Created by
V Viktor Schmidt

Usage
RubyGems: https://rubygems.org/gems/brakeman

$ bin/brakeman -AI

Run this command in your Rails app directory in the terminal:

rails app:template LOCATION="https://railsbytes.com/script/XnJsQ5"
Template Source

Review the code before running this template on your machine.

def do_bundle
  Bundler.with_original_env { run "bundle install" }
end

def print_green(heredoc)
  puts set_color heredoc, :green
end

def do_commit
  git :init
  git add: "."
  git commit: " -m 'Add Brakeman static analysis tool' "
end

def puts_usage
  say "\nUsage:"
  say "`bin/brakeman -Aq`"
end

say "\nApplying Brakeman static analysis tool..."
inject_into_file 'Gemfile', after: 'group :development do' do
  <<-RUBY

  # Brakeman detects security vulnerabilities in Ruby on Rails applications via static analysis.
  gem "brakeman", "~> 5.4", require: false
  RUBY
end

do_bundle

run "bundle binstubs brakeman"
run "bin/brakeman -AI"

say "\nAdding documentation for developers..."
create_file "doc/security.md", "# Security\n" unless File.exist? "doc/security.md"
append_file "doc/security.md" do
  <<~EOF  
  
  ## Brakeman

  [Brakeman](https://rubygems.org/gems/brakeman) detects security vulnerabilities in Ruby on Rails applications via static analysis.

  `$ bin/brakeman -AI`
  EOF
end

do_commit

print_green "\nAdded Brakeman successfully!"
puts_usage
Comments

Sign up or Login to leave a comment.

© 2023 GoRails, LLC