提交 7f7cae3f 编写于 作者: J Justin Collins

Raise an exception if no app is found, not exit

上级 d7f00569
......@@ -56,22 +56,23 @@ 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)
begin
if options[:previous_results_json]
vulns = Brakeman.compare options.merge(:quiet => options[:quiet])
puts MultiJson.dump(vulns, :pretty => true)
if options[:exit_on_warn] and (vulns[:new].count + vulns[:fixed].count > 0)
exit Brakeman::Warnings_Found_Exit_Code
end
else
#Run scan and output a report
tracker = Brakeman.run options.merge(:print_report => true, :quiet => options[:quiet])
if options[:exit_on_warn] and (vulns[:new].count + vulns[:fixed].count > 0)
exit Brakeman::Warnings_Found_Exit_Code
end
else
#Run scan and output a report
tracker = Brakeman.run options.merge(:print_report => true, :quiet => options[:quiet])
#Return error code if --exit-on-warn is used and warnings were found
if options[:exit_on_warn] and not tracker.checks.all_warnings.empty?
exit Brakeman::Warnings_Found_Exit_Code
#Return error code if --exit-on-warn is used and warnings were found
if options[:exit_on_warn] and not tracker.checks.all_warnings.empty?
exit Brakeman::Warnings_Found_Exit_Code
end
end
rescue Brakeman::Scanner::NoApplication => e
$stderr.puts e.message
end
......@@ -33,7 +33,7 @@ class Brakeman::Scanner
@app_tree = Brakeman::AppTree.from_options(options)
if !@app_tree.root || !@app_tree.exists?("app")
abort("Please supply the path to a Rails application.")
raise NoApplication, "Please supply the path to a Rails application."
end
if @app_tree.exists?("script/rails")
......@@ -355,4 +355,6 @@ class Brakeman::Scanner
def parse_ruby input
@ruby_parser.new.parse input
end
class NoApplication < RuntimeError; end
end
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册