提交 1d318d91 编写于 作者: J Justin

Merge pull request #631 from presidentbeef/no_warn_on_mass_assign_with_literal

Avoid warning about mass assignment with literals
...@@ -82,6 +82,8 @@ class Brakeman::CheckMassAssignment < Brakeman::BaseCheck ...@@ -82,6 +82,8 @@ class Brakeman::CheckMassAssignment < Brakeman::BaseCheck
confidence = CONFIDENCE[:low] confidence = CONFIDENCE[:low]
user_input = input.match user_input = input.match
end end
elsif node_type? call.first_arg, :lit, :str
return
else else
confidence = CONFIDENCE[:low] confidence = CONFIDENCE[:low]
user_input = nil user_input = nil
......
...@@ -139,4 +139,8 @@ class UsersController < ApplicationController ...@@ -139,4 +139,8 @@ class UsersController < ApplicationController
def test_sanitize def test_sanitize
@x = params[:x] @x = params[:x]
end end
def string_mass
User.new("stuff")
end
end end
...@@ -103,6 +103,17 @@ class RailsWithXssPluginTests < Test::Unit::TestCase ...@@ -103,6 +103,17 @@ class RailsWithXssPluginTests < Test::Unit::TestCase
:file => /users_controller\.rb/ :file => /users_controller\.rb/
end end
def test_mass_assignment_with_string
assert_no_warning :type => :warning,
:warning_code => 17,
:fingerprint => "2893b1a48ec56548a5a48d38324c5d78f7845066713ad79bb0ec17032672c862",
:warning_type => "Mass Assignment",
:line => 97,
:message => /^Unprotected\ mass\ assignment/,
:confidence => 2,
:relative_path => "app/controllers/other_controller.rb",
:user_input => nil
end
def test_redirect_to_model_instance def test_redirect_to_model_instance
assert_no_warning :type => :warning, assert_no_warning :type => :warning,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册