Created
January 5, 2012 01:56
-
-
Save presidentbeef/1563286 to your computer and use it in GitHub Desktop.
Rescanning changed files
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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