提交 b6e2dfad 编写于 作者: J Justin

Merge pull request #446 from presidentbeef/remove_rescue_exception

Remove `rescue Exception` instances
...@@ -100,7 +100,7 @@ class Brakeman::Checks ...@@ -100,7 +100,7 @@ class Brakeman::Checks
begin begin
check.run_check check.run_check
rescue Exception => e rescue => e
tracker.error e tracker.error e
end end
...@@ -138,7 +138,7 @@ class Brakeman::Checks ...@@ -138,7 +138,7 @@ class Brakeman::Checks
begin begin
check.run_check check.run_check
rescue Exception => e rescue => e
error_mutex.synchronize do error_mutex.synchronize do
tracker.error e tracker.error e
end end
......
...@@ -58,7 +58,7 @@ class Brakeman::AliasProcessor < Brakeman::SexpProcessor ...@@ -58,7 +58,7 @@ class Brakeman::AliasProcessor < Brakeman::SexpProcessor
e e
end end
end end
rescue Exception => err rescue => err
@tracker.error err if @tracker @tracker.error err if @tracker
end end
......
...@@ -20,7 +20,7 @@ class Brakeman::ErbTemplateProcessor < Brakeman::TemplateProcessor ...@@ -20,7 +20,7 @@ class Brakeman::ErbTemplateProcessor < Brakeman::TemplateProcessor
@inside_concat = false @inside_concat = false
if exp.second_arg if exp.second_arg
raise Exception.new("Did not expect more than a single argument to _erbout.concat") raise "Did not expect more than a single argument to _erbout.concat"
end end
arg = exp.first_arg arg = exp.first_arg
......
...@@ -30,7 +30,7 @@ class Brakeman::HamlTemplateProcessor < Brakeman::TemplateProcessor ...@@ -30,7 +30,7 @@ class Brakeman::HamlTemplateProcessor < Brakeman::TemplateProcessor
out = exp.first_arg = process(arg) out = exp.first_arg = process(arg)
@inside_concat = false @inside_concat = false
else else
raise Exception.new("Empty _hamlout.#{method}()?") raise "Empty _hamlout.#{method}()?"
end end
if string? out if string? out
...@@ -46,7 +46,7 @@ class Brakeman::HamlTemplateProcessor < Brakeman::TemplateProcessor ...@@ -46,7 +46,7 @@ class Brakeman::HamlTemplateProcessor < Brakeman::TemplateProcessor
Sexp.new :format, out Sexp.new :format, out
end end
else else
raise Exception.new("Unrecognized action on _hamlout: #{method}") raise "Unrecognized action on _hamlout: #{method}"
end end
end end
......
...@@ -18,7 +18,7 @@ class Brakeman::OutputProcessor < Ruby2Ruby ...@@ -18,7 +18,7 @@ class Brakeman::OutputProcessor < Ruby2Ruby
def process exp def process exp
begin begin
super exp if sexp? exp and not exp.empty? super exp if sexp? exp and not exp.empty?
rescue Exception => e rescue => e
Brakeman.debug "While formatting #{exp}: #{e}\n#{e.backtrace.join("\n")}" Brakeman.debug "While formatting #{exp}: #{e}\n#{e.backtrace.join("\n")}"
end end
end end
......
...@@ -26,7 +26,7 @@ class Brakeman::TemplateProcessor < Brakeman::BaseProcessor ...@@ -26,7 +26,7 @@ class Brakeman::TemplateProcessor < Brakeman::BaseProcessor
def process exp def process exp
begin begin
super super
rescue Exception => e rescue => e
except = e.exception("Error when processing #{@current_template[:name]}: #{e.message}") except = e.exception("Error when processing #{@current_template[:name]}: #{e.message}")
except.set_backtrace(e.backtrace) except.set_backtrace(e.backtrace)
raise except raise except
......
...@@ -95,7 +95,7 @@ class Brakeman::Scanner ...@@ -95,7 +95,7 @@ class Brakeman::Scanner
@processor.process_config(parse_ruby(@app_tree.read(path))) @processor.process_config(parse_ruby(@app_tree.read(path)))
end end
rescue Exception => e rescue => e
Brakeman.notify "[Notice] Error while processing #{path}" Brakeman.notify "[Notice] Error while processing #{path}"
tracker.error e.exception(e.message + "\nwhile processing #{path}"), e.backtrace tracker.error e.exception(e.message + "\nwhile processing #{path}"), e.backtrace
end end
...@@ -111,7 +111,7 @@ class Brakeman::Scanner ...@@ -111,7 +111,7 @@ class Brakeman::Scanner
@processor.process_gems(parse_ruby(@app_tree.read("Gemfile"))) @processor.process_gems(parse_ruby(@app_tree.read("Gemfile")))
end end
end end
rescue Exception => e rescue => e
Brakeman.notify "[Notice] Error while processing Gemfile." Brakeman.notify "[Notice] Error while processing Gemfile."
tracker.error e.exception(e.message + "\nWhile processing Gemfile"), e.backtrace tracker.error e.exception(e.message + "\nWhile processing Gemfile"), e.backtrace
end end
...@@ -131,7 +131,7 @@ class Brakeman::Scanner ...@@ -131,7 +131,7 @@ class Brakeman::Scanner
@processor.process_initializer(path, parse_ruby(@app_tree.read_path(path))) @processor.process_initializer(path, parse_ruby(@app_tree.read_path(path)))
rescue Racc::ParseError => e rescue Racc::ParseError => e
tracker.error e, "could not parse #{path}. There is probably a typo in the file. Test it with 'ruby_parse #{path}'" tracker.error e, "could not parse #{path}. There is probably a typo in the file. Test it with 'ruby_parse #{path}'"
rescue Exception => e rescue => e
tracker.error e.exception(e.message + "\nWhile processing #{path}"), e.backtrace tracker.error e.exception(e.message + "\nWhile processing #{path}"), e.backtrace
end end
end end
...@@ -162,7 +162,7 @@ class Brakeman::Scanner ...@@ -162,7 +162,7 @@ class Brakeman::Scanner
@processor.process_lib parse_ruby(@app_tree.read_path(path)), path @processor.process_lib parse_ruby(@app_tree.read_path(path)), path
rescue Racc::ParseError => e rescue Racc::ParseError => e
tracker.error e, "could not parse #{path}. There is probably a typo in the file. Test it with 'ruby_parse #{path}'" tracker.error e, "could not parse #{path}. There is probably a typo in the file. Test it with 'ruby_parse #{path}'"
rescue Exception => e rescue => e
tracker.error e.exception(e.message + "\nWhile processing #{path}"), e.backtrace tracker.error e.exception(e.message + "\nWhile processing #{path}"), e.backtrace
end end
end end
...@@ -174,7 +174,7 @@ class Brakeman::Scanner ...@@ -174,7 +174,7 @@ class Brakeman::Scanner
if @app_tree.exists?("config/routes.rb") if @app_tree.exists?("config/routes.rb")
begin begin
@processor.process_routes parse_ruby(@app_tree.read("config/routes.rb")) @processor.process_routes parse_ruby(@app_tree.read("config/routes.rb"))
rescue Exception => e rescue => e
tracker.error e.exception(e.message + "\nWhile processing routes.rb"), e.backtrace tracker.error e.exception(e.message + "\nWhile processing routes.rb"), e.backtrace
Brakeman.notify "[Notice] Error while processing routes - assuming all public controller methods are actions." Brakeman.notify "[Notice] Error while processing routes - assuming all public controller methods are actions."
options[:assume_all_routes] = true options[:assume_all_routes] = true
...@@ -219,7 +219,7 @@ class Brakeman::Scanner ...@@ -219,7 +219,7 @@ class Brakeman::Scanner
@processor.process_controller(parse_ruby(@app_tree.read_path(path)), path) @processor.process_controller(parse_ruby(@app_tree.read_path(path)), path)
rescue Racc::ParseError => e rescue Racc::ParseError => e
tracker.error e, "could not parse #{path}. There is probably a typo in the file. Test it with 'ruby_parse #{path}'" tracker.error e, "could not parse #{path}. There is probably a typo in the file. Test it with 'ruby_parse #{path}'"
rescue Exception => e rescue => e
tracker.error e.exception(e.message + "\nWhile processing #{path}"), e.backtrace tracker.error e.exception(e.message + "\nWhile processing #{path}"), e.backtrace
end end
end end
...@@ -305,7 +305,7 @@ class Brakeman::Scanner ...@@ -305,7 +305,7 @@ class Brakeman::Scanner
tracker.error e, "could not parse #{path}" tracker.error e, "could not parse #{path}"
rescue Haml::Error => e rescue Haml::Error => e
tracker.error e, ["While compiling HAML in #{path}"] << e.backtrace tracker.error e, ["While compiling HAML in #{path}"] << e.backtrace
rescue Exception => e rescue StandardError, LoadError => e
tracker.error e.exception(e.message + "\nWhile processing #{path}"), e.backtrace tracker.error e.exception(e.message + "\nWhile processing #{path}"), e.backtrace
end end
end end
...@@ -339,7 +339,7 @@ class Brakeman::Scanner ...@@ -339,7 +339,7 @@ class Brakeman::Scanner
@processor.process_model(parse_ruby(@app_tree.read_path(path)), path) @processor.process_model(parse_ruby(@app_tree.read_path(path)), path)
rescue Racc::ParseError => e rescue Racc::ParseError => e
tracker.error e, "could not parse #{path}" tracker.error e, "could not parse #{path}"
rescue Exception => e rescue => e
tracker.error e.exception(e.message + "\nWhile processing #{path}"), e.backtrace tracker.error e.exception(e.message + "\nWhile processing #{path}"), e.backtrace
end end
end end
......
...@@ -88,7 +88,7 @@ class Brakeman::SexpProcessor ...@@ -88,7 +88,7 @@ class Brakeman::SexpProcessor
def error_handler(type, exp=nil) # :nodoc: def error_handler(type, exp=nil) # :nodoc:
begin begin
return yield return yield
rescue StandardError => err rescue => err
warn "#{err.class} Exception thrown while processing #{type} for sexp #{exp.inspect} #{caller.inspect}" if $DEBUG warn "#{err.class} Exception thrown while processing #{type} for sexp #{exp.inspect} #{caller.inspect}" if $DEBUG
raise raise
end end
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册