Skip to content

Instantly share code, notes, and snippets.

@presidentbeef
Created January 5, 2012 01:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save presidentbeef/1563286 to your computer and use it in GitHub Desktop.
Save presidentbeef/1563286 to your computer and use it in GitHub Desktop.
Rescanning changed files
my_rails_app = "your/path/here"
changed_files = ["changed/files/here"]
require 'brakeman'
#Do initial scan
tracker = Brakeman.run :app_path => my_rails_app
puts "Warnings: #{tracker.checks.all_warnings.length}"
puts "Errors: #{tracker.errors.length}"
#Wait for it...
print "Press enter to rescan..."
gets
#This will rescan files and run the checks again, returning a Brakeman::RescanReport
report = Brakeman.rescan tracker, changed_files
#Output information if report changed
if report.warnings_changed?
puts "Warnings: #{report.all_warnings.length}"
puts "Errors: #{tracker.errors.length}"
#Report difference in report (if any)
puts "New: #{report.new_warnings.length}"
report.new_warnings.each do |w|
puts w.format_message
end
puts "Fixed: #{report.fixed_warnings.length}"
report.fixed_warnings.each do |w|
puts w.format_message
end
else
puts "No warnings changed."
puts "Total warnings: #{report.all_warnings.length}"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment