提交 0f44dd81 编写于 作者: A aj0strow

rails 4 no warning for friendly model in redirect_to (friendly_id gem compatibility)

上级 6778223c
......@@ -128,7 +128,7 @@ class Brakeman::CheckRedirect < Brakeman::BaseCheck
if node_type? exp, :or
model_instance? exp.lhs or model_instance? exp.rhs
elsif call? exp
if model_name? exp.target and
if model_name? exp.target or friendly_model? exp.target and
(@model_find_calls.include? exp.method or exp.method.to_s.match(/^find_by_/))
true
else
......@@ -137,6 +137,12 @@ class Brakeman::CheckRedirect < Brakeman::BaseCheck
end
end
#Returns true if exp is (probably) a friendly model instance
#using the FriendlyId gem
def friendly_model? exp
call? exp and model_name? exp.target and exp.method == :friendly
end
#Returns true if exp is (probably) a decorated model instance
#using the Draper gem
def decorated_model? exp
......
class FriendlyController
def find
@user = User.friendly.find(params[:id])
redirect_to @user
end
end
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册