Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.