Class to make reporting of rescan results simpler to deal with
Returns an array of all warnings found
# File lib/brakeman/rescanner.rb, line 381 def all_warnings @all_warnings ||= new_results.all_warnings end
Returns true if any warnings were found (new or old)
# File lib/brakeman/rescanner.rb, line 376 def any_warnings? not all_warnings.empty? end
Returns a hash of arrays for :new and :fixed warnings
# File lib/brakeman/rescanner.rb, line 403 def diff @diff ||= @new_results.diff(@old_results) end
Returns an array of warnings which were in the old report and the new report
# File lib/brakeman/rescanner.rb, line 408 def existing_warnings @old ||= all_warnings.select do |w| not new_warnings.include? w end end
Returns an array of warnings which were in the old report but are not in the new report after rescanning
# File lib/brakeman/rescanner.rb, line 387 def fixed_warnings diff[:fixed] end
Returns an array of warnings which were in the new report but were not in the old report
# File lib/brakeman/rescanner.rb, line 393 def new_warnings diff[:new] end
Output total, fixed, and new warnings
# File lib/brakeman/rescanner.rb, line 415 def to_s(verbose = false) if !verbose Total warnings: #{all_warnings.length}Fixed warnings: #{fixed_warnings.length}New warnings: #{new_warnings.length} else #Eventually move this to different method, or make default to_s out = "" {:fixed => fixed_warnings, :new => new_warnings, :existing => existing_warnings}.each do |warning_type, warnings| if warnings.length > 0 out << "#{warning_type.to_s.titleize} warnings: #{warnings.length}\n" table = Terminal::Table.new(:headings => ["Confidence", "Class", "Method", "Warning Type", "Message"]) do |t| warnings.sort_by { |w| w.confidence}.each do |warning| w = warning.to_row w["Confidence"] = Brakeman::Report::TEXT_CONFIDENCE[w["Confidence"]] t << [w["Confidence"], w["Class"], w["Method"], w["Warning Type"], w["Message"]] end end out << truncate_table(table.to_s) end end out end end
Generated with the Darkfish Rdoc Generator 2.