提交 b904ee56 编写于 作者: J Justin Collins

Merge branch 'clearer_handling_of_quiet_default'

......@@ -52,6 +52,10 @@ trap("INT") do
exit!
end
if options[:quiet].nil?
options[:quiet] = :command_line
end
if options[:previous_results_json]
vulns = Brakeman.compare options.merge(:quiet => options[:quiet])
puts MultiJson.dump(vulns, :pretty => true)
......
......@@ -62,9 +62,18 @@ module Brakeman
if options.is_a? String
options = { :app_path => options }
end
if options[:quiet] == :command_line
command_line = true
options.delete :quiet
end
options = default_options.merge(load_options(options[:config_file], options[:quiet])).merge(options)
if options[:quiet].nil? and not command_line
options[:quiet] = true
end
options[:app_path] = File.expand_path(options[:app_path])
options[:output_formats] = get_output_formats options
......@@ -112,7 +121,6 @@ module Brakeman
:message_limit => 100,
:parallel_checks => true,
:relative_path => false,
:quiet => true,
:report_progress => true,
:html_style => "#{File.expand_path(File.dirname(__FILE__))}/brakeman/format/style.css"
}
......
......@@ -131,9 +131,9 @@ class ConfigTests < Test::Unit::TestCase
assert final_options[:quiet], "Expected quiet option to be true, but was #{final_options[:quiet]}"
end
def test_quiet_option_with_nil
def test_quiet_command_line_default
options = {
:quiet => nil,
:quiet => :command_line,
:app_path => "/tmp" #doesn't need to be real
}
......@@ -141,6 +141,29 @@ class ConfigTests < Test::Unit::TestCase
assert_nil final_options[:quiet]
end
def test_quiet_inconfig_with_command_line
config = Tempfile.new("config")
config.write <<-YAML.strip
---
:quiet: true
YAML
config.close
options = {
:quiet => :command_line,
:config_file => config.path,
:app_path => "#{TEST_PATH}/apps/rails4",
:run_checks => []
}
assert_equal "", capture_output {
Brakeman.run options
config.unlink
}[1]
end
def output_format_tester options, expected_options
output_formats = Brakeman.get_output_formats(options)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册