Permalink
Browse files

Make --exit-on-warn the default

closes #852
  • Loading branch information...
presidentbeef committed Aug 23, 2017
1 parent 4f7dc7f commit aa1f4a3b47d3d9a80922270a618e6ae9c41d2870
Showing with 26 additions and 12 deletions.
  1. +11 −9 lib/brakeman.rb
  2. +1 −1 lib/brakeman/options.rb
  3. +14 −2 test/tests/commandline.rb
View
@@ -71,6 +71,7 @@ def self.run options
if @quiet
options[:report_progress] = false
end
scan options
end
@@ -156,23 +157,24 @@ def self.config_file custom_location, app_path
#Default set of options
def self.default_options
{ :assume_all_routes => true,
:skip_checks => Set.new,
:check_arguments => true,
:safe_methods => Set.new,
:min_confidence => 2,
:combine_locations => true,
:collapse_mass_assignment => false,
:combine_locations => true,
:engine_paths => ["engines/*"],
:exit_on_warn => true,
:highlight_user_input => true,
:ignore_redirect_to_model => true,
:html_style => "#{File.expand_path(File.dirname(__FILE__))}/brakeman/format/style.css",
:ignore_model_output => false,
:ignore_redirect_to_model => true,
:index_libs => true,
:message_limit => 100,
:min_confidence => 2,
:output_color => true,
:parallel_checks => true,
:relative_path => false,
:report_progress => true,
:html_style => "#{File.expand_path(File.dirname(__FILE__))}/brakeman/format/style.css",
:output_color => true,
:engine_paths => ["engines/*"]
:safe_methods => Set.new,
:skip_checks => Set.new,
}
end
@@ -508,7 +510,7 @@ def self.check_for_missing_checks included_checks, excluded_checks
missing = Brakeman::Checks.missing_checks(included_checks || Set.new, excluded_checks || Set.new)
unless missing.empty?
raise MissingChecksError, "Could not find specified check#{missing.length > 1 ? 's' : ''}: #{missing.to_a.join(', ')}"
raise MissingChecksError, "Could not find specified check#{missing.length > 1 ? 's' : ''}: #{missing.map {|c| "`#{c}`"}.join(', ')}"
end
end
View
@@ -55,7 +55,7 @@ def create_option_parser options
options[:quiet] = quiet
end
opts.on( "-z", "--[no-]exit-on-warn", "Exit code is non-zero if warnings found") do |exit_on_warn|
opts.on( "-z", "--[no-]exit-on-warn", "Exit code is non-zero if warnings found (Default)") do |exit_on_warn|
options[:exit_on_warn] = exit_on_warn
end
View
@@ -113,9 +113,21 @@ def test_show_help
end
end
def test_exit_on_warn
def test_exit_on_warn_default
assert_exit Brakeman::Warnings_Found_Exit_Code do
scan_app "--exit-on-warn"
scan_app
end
end
def test_no_exit_on_warn
assert_exit do
scan_app "--no-exit-on-warn"
end
end
def test_exit_on_warn_no_warnings
assert_exit do
scan_app "-t", "None"
end
end
end

0 comments on commit aa1f4a3

Please sign in to comment.