提交 8a31492e 编写于 作者: J Justin

Merge pull request #28 from presidentbeef/add_rake_task

Add --rake option to install rake task
which closes #26
......@@ -27,6 +27,9 @@ elsif options[:show_help]
elsif options[:show_version]
puts "brakeman #{Brakeman::Version}"
exit
elsif options[:install_rake_task]
Brakeman.install_rake_task
exit
end
#Set application path according to the commandline arguments
......
......@@ -145,6 +145,32 @@ module Brakeman
$stderr.puts Checks.checks.map { |c| c.to_s.match(/^Brakeman::(.*)$/)[1] }.sort.join "\n"
end
def self.install_rake_task
if not File.exists? "Rakefile"
abort "No Rakefile detected"
elsif File.exists? "lib/tasks/brakeman.rake"
abort "Task already exists"
end
require 'fileutils'
if not File.exists? "lib/tasks"
warn "Creating lib/tasks"
FileUtils.mkdir_p "lib/tasks"
end
path = File.expand_path(File.dirname(__FILE__))
FileUtils.cp "#{path}/brakeman/brakeman.rake", "lib/tasks/brakeman.rake"
if File.exists? "lib/tasks/brakeman.rake"
warn "Task created in lib/tasks/brakeman.rake"
warn "Usage: rake brakeman:run[output_file]"
else
warn "Could not create task"
end
end
def self.dump_config options
if options[:create_config].is_a? String
file = options[:create_config]
......
namespace :brakeman do
desc "Run Brakeman"
task :run, :output_file do |t, args|
require 'brakeman'
tracker = Brakeman.run :app_path => ".", :output_file => args[:output_file]
if args[:output_file].nil?
puts tracker.report
end
end
end
......@@ -175,6 +175,10 @@ module Brakeman::Options
options[:list_checks] = true
end
opts.on "--rake", "Create rake task to run Brakeman" do
options[:install_rake_task] = true
end
opts.on "-v", "--version", "Show Brakeman version" do
options[:show_version] = true
end
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册