diff --git a/lib/brakeman/checks.rb b/lib/brakeman/checks.rb index 2ead86a87303cbea6de51e9e031f8ee6bfa587da..9bda617618e05c2adf996e287f639414c8214e2c 100644 --- a/lib/brakeman/checks.rb +++ b/lib/brakeman/checks.rb @@ -100,7 +100,7 @@ class Brakeman::Checks begin check.run_check - rescue Exception => e + rescue => e tracker.error e end @@ -138,7 +138,7 @@ class Brakeman::Checks begin check.run_check - rescue Exception => e + rescue => e error_mutex.synchronize do tracker.error e end diff --git a/lib/brakeman/processors/alias_processor.rb b/lib/brakeman/processors/alias_processor.rb index 87989338b2c0576a345b105d6e0227b68391c355..975b84d96d21ba69a2b8cd4b375939a586ae1530 100644 --- a/lib/brakeman/processors/alias_processor.rb +++ b/lib/brakeman/processors/alias_processor.rb @@ -58,7 +58,7 @@ class Brakeman::AliasProcessor < Brakeman::SexpProcessor e end end - rescue Exception => err + rescue => err @tracker.error err if @tracker end diff --git a/lib/brakeman/processors/erb_template_processor.rb b/lib/brakeman/processors/erb_template_processor.rb index cf1ce00b0016b4ef8d64ba5b1b8cbf02cbd8bd34..a5afb94e2e8538c35a0d372f7ed850406e9de1e8 100644 --- a/lib/brakeman/processors/erb_template_processor.rb +++ b/lib/brakeman/processors/erb_template_processor.rb @@ -20,7 +20,7 @@ class Brakeman::ErbTemplateProcessor < Brakeman::TemplateProcessor @inside_concat = false 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 arg = exp.first_arg diff --git a/lib/brakeman/processors/haml_template_processor.rb b/lib/brakeman/processors/haml_template_processor.rb index 9bd31bf902d8c05ef64df32f020d31282ac49ddf..2b19b0ae1924c8302a7cae9da005c0e4c62f378e 100644 --- a/lib/brakeman/processors/haml_template_processor.rb +++ b/lib/brakeman/processors/haml_template_processor.rb @@ -30,7 +30,7 @@ class Brakeman::HamlTemplateProcessor < Brakeman::TemplateProcessor out = exp.first_arg = process(arg) @inside_concat = false else - raise Exception.new("Empty _hamlout.#{method}()?") + raise "Empty _hamlout.#{method}()?" end if string? out @@ -46,7 +46,7 @@ class Brakeman::HamlTemplateProcessor < Brakeman::TemplateProcessor Sexp.new :format, out end else - raise Exception.new("Unrecognized action on _hamlout: #{method}") + raise "Unrecognized action on _hamlout: #{method}" end end diff --git a/lib/brakeman/processors/output_processor.rb b/lib/brakeman/processors/output_processor.rb index fa94b3fc09e3569542ee7654d32382f1f93749c5..afb6c3d0b222d6bd36785b05fb38a39f37b57d7d 100644 --- a/lib/brakeman/processors/output_processor.rb +++ b/lib/brakeman/processors/output_processor.rb @@ -18,7 +18,7 @@ class Brakeman::OutputProcessor < Ruby2Ruby def process exp begin 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")}" end end diff --git a/lib/brakeman/processors/template_processor.rb b/lib/brakeman/processors/template_processor.rb index 18d35490e5a510bd42fc839f2c179a815fd1592a..8abbdbcdddd6a8f377f9bff56e58477c5d5cd9f9 100644 --- a/lib/brakeman/processors/template_processor.rb +++ b/lib/brakeman/processors/template_processor.rb @@ -26,7 +26,7 @@ class Brakeman::TemplateProcessor < Brakeman::BaseProcessor def process exp begin super - rescue Exception => e + rescue => e except = e.exception("Error when processing #{@current_template[:name]}: #{e.message}") except.set_backtrace(e.backtrace) raise except diff --git a/lib/brakeman/scanner.rb b/lib/brakeman/scanner.rb index 0816df43aab8a4e7f9e7ef7b91229b39aacc6f3d..13121ddae47a74631e28ec99ac6d7c48a1ece4e0 100644 --- a/lib/brakeman/scanner.rb +++ b/lib/brakeman/scanner.rb @@ -95,7 +95,7 @@ class Brakeman::Scanner @processor.process_config(parse_ruby(@app_tree.read(path))) end - rescue Exception => e + rescue => e Brakeman.notify "[Notice] Error while processing #{path}" tracker.error e.exception(e.message + "\nwhile processing #{path}"), e.backtrace end @@ -111,7 +111,7 @@ class Brakeman::Scanner @processor.process_gems(parse_ruby(@app_tree.read("Gemfile"))) end end - rescue Exception => e + rescue => e Brakeman.notify "[Notice] Error while processing Gemfile." tracker.error e.exception(e.message + "\nWhile processing Gemfile"), e.backtrace end @@ -131,7 +131,7 @@ class Brakeman::Scanner @processor.process_initializer(path, parse_ruby(@app_tree.read_path(path))) 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}'" - rescue Exception => e + rescue => e tracker.error e.exception(e.message + "\nWhile processing #{path}"), e.backtrace end end @@ -162,7 +162,7 @@ class Brakeman::Scanner @processor.process_lib parse_ruby(@app_tree.read_path(path)), path 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}'" - rescue Exception => e + rescue => e tracker.error e.exception(e.message + "\nWhile processing #{path}"), e.backtrace end end @@ -174,7 +174,7 @@ class Brakeman::Scanner if @app_tree.exists?("config/routes.rb") begin @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 Brakeman.notify "[Notice] Error while processing routes - assuming all public controller methods are actions." options[:assume_all_routes] = true @@ -219,7 +219,7 @@ class Brakeman::Scanner @processor.process_controller(parse_ruby(@app_tree.read_path(path)), path) 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}'" - rescue Exception => e + rescue => e tracker.error e.exception(e.message + "\nWhile processing #{path}"), e.backtrace end end @@ -305,7 +305,7 @@ class Brakeman::Scanner tracker.error e, "could not parse #{path}" rescue Haml::Error => e 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 end end @@ -339,7 +339,7 @@ class Brakeman::Scanner @processor.process_model(parse_ruby(@app_tree.read_path(path)), path) rescue Racc::ParseError => e tracker.error e, "could not parse #{path}" - rescue Exception => e + rescue => e tracker.error e.exception(e.message + "\nWhile processing #{path}"), e.backtrace end end diff --git a/lib/ruby_parser/bm_sexp_processor.rb b/lib/ruby_parser/bm_sexp_processor.rb index be013a1734bf3589c2b1777d67a54ba03f38b477..e26efc7b00665f509777880d7b5539e389fea34d 100644 --- a/lib/ruby_parser/bm_sexp_processor.rb +++ b/lib/ruby_parser/bm_sexp_processor.rb @@ -88,7 +88,7 @@ class Brakeman::SexpProcessor def error_handler(type, exp=nil) # :nodoc: begin return yield - rescue StandardError => err + rescue => err warn "#{err.class} Exception thrown while processing #{type} for sexp #{exp.inspect} #{caller.inspect}" if $DEBUG raise end