提交 caa2a309 编写于 作者: J Justin

Merge pull request #417 from presidentbeef/stop_raising_exceptions_in_class_name

Stop raising exception in ProcessorHelper#class_name
......@@ -432,13 +432,7 @@ class Brakeman::BaseCheck < Brakeman::SexpProcessor
if exp.is_a? Symbol
@models.include? exp
elsif sexp? exp
klass = nil
begin
klass = class_name exp
rescue StandardError
end
klass and @models.include? klass
@models.include? class_name(exp)
else
false
end
......
......@@ -23,13 +23,7 @@ class Brakeman::ControllerProcessor < Brakeman::BaseProcessor
#s(:class, NAME, PARENT, s(:scope ...))
def process_class exp
name = class_name(exp.class_name)
begin
parent = class_name exp.parent_name
rescue StandardError => e
Brakeman.debug e
parent = nil
end
parent = class_name(exp.parent_name)
#If inside a real controller, treat any other classes as libraries.
#But if not inside a controller already, then the class may include
......
......@@ -122,11 +122,7 @@ class Brakeman::FindAllCalls < Brakeman::BaseProcessor
when :true, :false
exp[0]
when :colon2
begin
class_name exp
rescue StandardError
exp
end
class_name exp
when :self
@current_class || @current_module || nil
else
......
......@@ -52,6 +52,7 @@ module Brakeman::ProcessorHelper
end
#Returns a class name as a Symbol.
#If class name cannot be determined, returns _exp_.
def class_name exp
case exp
when Sexp
......@@ -69,14 +70,14 @@ module Brakeman::ProcessorHelper
when :self
@current_class || @current_module || nil
else
raise "Error: Cannot get class name from #{exp}"
exp
end
when Symbol
exp
when nil
nil
else
raise "Error: Cannot get class name from #{exp}"
exp
end
end
end
......@@ -161,9 +161,10 @@ module Brakeman::RenderHelper
if call? sexp
get_class_target sexp.target
else
begin
class_name sexp
rescue
klass = class_name sexp
if klass.is_a? Symbol
klass
else
nil
end
end
......
......@@ -30,12 +30,7 @@ class Brakeman::LibraryProcessor < Brakeman::BaseProcessor
if @tracker.libs[name]
@current_class = @tracker.libs[name]
else
begin
parent = class_name exp.parent_name
rescue StandardError => e
Brakeman.debug e
parent = nil
end
parent = class_name exp.parent_name
@current_class = { :name => name,
:parent => parent,
......
......@@ -27,12 +27,7 @@ class Brakeman::ModelProcessor < Brakeman::BaseProcessor
Brakeman.debug "[Notice] Skipping inner class: #{name}"
ignore
else
begin
parent = class_name exp.parent_name
rescue StandardError => e
Brakeman.debug e
parent = nil
end
parent = class_name exp.parent_name
@model = { :name => name,
:parent => parent,
......
......@@ -85,13 +85,8 @@ class Brakeman::TemplateAliasProcessor < Brakeman::AliasProcessor
if exp.method == :all or exp.method.to_s[0,4] == "find"
models = Set.new @tracker.models.keys
begin
name = class_name target
return target if models.include?(name)
rescue StandardError
end
name = class_name target
return target if models.include?(name)
end
return get_model_target(target)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册