lib/brakeman/commandline.rb in brakeman-4.8.2 vs lib/brakeman/commandline.rb in brakeman-4.9.0

- old
+ new

@@ -100,10 +100,17 @@ app_path = argv[-1] else app_path = "." end + if options[:ensure_ignore_notes] and options[:previous_results_json] + warn '[Notice] --ensure-ignore-notes may not be used at the same ' \ + 'time as --compare. Deactivating --ensure-ignore-notes. ' \ + 'Please see `brakeman --help` for valid options' + options[:ensure_ignore_notes] = false + end + return options, app_path end # Exits with the given exit code and prints out the message, if given. # @@ -113,17 +120,34 @@ exit exit_code end # Runs a regular report based on the options provided. def regular_report options - tracker = run_brakeman options + tracker = run_brakeman options + ensure_ignore_notes_failed = false + if tracker.options[:ensure_ignore_notes] + fingerprints = Brakeman::ignore_file_entries_with_empty_notes tracker.ignored_filter&.file + + unless fingerprints.empty? + ensure_ignore_notes_failed = true + warn '[Error] Notes required for all ignored warnings when ' \ + '--ensure-ignore-notes is set. No notes provided for these ' \ + 'warnings: ' + fingerprints.each { |f| warn f } + end + end + if tracker.options[:exit_on_warn] and not tracker.filtered_warnings.empty? quit Brakeman::Warnings_Found_Exit_Code end if tracker.options[:exit_on_error] and tracker.errors.any? quit Brakeman::Errors_Found_Exit_Code + end + + if ensure_ignore_notes_failed + quit Brakeman::Empty_Ignore_Note_Exit_Code end end # Actually run Brakeman. #