提交 5dc5db41 编写于 作者: J Justin Collins

Add check for CVE-2012-2695

上级 e807ed13
...@@ -43,6 +43,9 @@ class Brakeman::CheckSQL < Brakeman::BaseCheck ...@@ -43,6 +43,9 @@ class Brakeman::CheckSQL < Brakeman::BaseCheck
Brakeman.debug "Checking version of Rails for CVE-2012-2661" Brakeman.debug "Checking version of Rails for CVE-2012-2661"
check_rails_version_for_cve_2012_2661 check_rails_version_for_cve_2012_2661
Brakeman.debug "Checking version of Rails for CVE-2012-2695"
check_rails_version_for_cve_2012_2695
Brakeman.debug "Processing possible SQL calls" Brakeman.debug "Processing possible SQL calls"
calls.each do |c| calls.each do |c|
process_result c process_result c
...@@ -104,6 +107,15 @@ class Brakeman::CheckSQL < Brakeman::BaseCheck ...@@ -104,6 +107,15 @@ class Brakeman::CheckSQL < Brakeman::BaseCheck
end end
end end
def check_rails_version_for_cve_2012_2695
if version_between?("2.0.0", "3.0.0") || version_between?("3.0.0", "3.0.13") || version_between?("3.1.0", "3.1.5") || version_between?("3.2.0", "3.2.5")
warn :warning_type => 'SQL Injection',
:message => 'All versions of Rails before 3.0.14, 3.1.6, and 3.2.6 contain a SQL Injection Vulnerability: CVE-2012-2695; Upgrade to 3.2.6, 3.1.6, 3.0.14',
:confidence => CONFIDENCE[:high],
:file => gemfile_or_environment
end
end
def process_scope_with_block model_name, args def process_scope_with_block model_name, args
scope_name = args[1][1] scope_name = args[1][1]
block = args[-1][-1] block = args[-1][-1]
......
...@@ -12,13 +12,13 @@ class Rails2Tests < Test::Unit::TestCase ...@@ -12,13 +12,13 @@ class Rails2Tests < Test::Unit::TestCase
:controller => 1, :controller => 1,
:model => 2, :model => 2,
:template => 27, :template => 27,
:warning => 27 } :warning => 28 }
else else
@expected ||= { @expected ||= {
:controller => 1, :controller => 1,
:model => 2, :model => 2,
:template => 27, :template => 27,
:warning => 28 } :warning => 29 }
end end
end end
...@@ -172,6 +172,13 @@ class Rails2Tests < Test::Unit::TestCase ...@@ -172,6 +172,13 @@ class Rails2Tests < Test::Unit::TestCase
:confidence => 0 :confidence => 0
end end
def test_rails_cve_2012_2695
assert_warning :type => :warning,
:warning_type => "SQL Injection",
:message => /CVE-2012-2695/,
:confidence => 0
end
def test_sql_injection_find_by_sql def test_sql_injection_find_by_sql
assert_warning :type => :warning, assert_warning :type => :warning,
:warning_type => "SQL Injection", :warning_type => "SQL Injection",
......
...@@ -15,7 +15,7 @@ class Rails3Tests < Test::Unit::TestCase ...@@ -15,7 +15,7 @@ class Rails3Tests < Test::Unit::TestCase
:controller => 1, :controller => 1,
:model => 5, :model => 5,
:template => 22, :template => 22,
:warning => 25 :warning => 26
} }
end end
...@@ -183,6 +183,14 @@ class Rails3Tests < Test::Unit::TestCase ...@@ -183,6 +183,14 @@ class Rails3Tests < Test::Unit::TestCase
:file => /Gemfile/ :file => /Gemfile/
end end
def test_rails_cve_2012_2695
assert_warning :type => :warning,
:warning_type => "SQL Injection",
:message => /CVE-2012-2695/,
:confidence => 0,
:file => /Gemfile/
end
def test_sql_injection_find_by_sql def test_sql_injection_find_by_sql
assert_warning :type => :warning, assert_warning :type => :warning,
:warning_type => "SQL Injection", :warning_type => "SQL Injection",
......
...@@ -15,7 +15,7 @@ class Rails31Tests < Test::Unit::TestCase ...@@ -15,7 +15,7 @@ class Rails31Tests < Test::Unit::TestCase
:model => 0, :model => 0,
:template => 4, :template => 4,
:controller => 1, :controller => 1,
:warning => 39 } :warning => 40 }
end end
def test_without_protection def test_without_protection
...@@ -96,6 +96,14 @@ class Rails31Tests < Test::Unit::TestCase ...@@ -96,6 +96,14 @@ class Rails31Tests < Test::Unit::TestCase
:file => /Gemfile/ :file => /Gemfile/
end end
def test_rails_cve_2012_2695
assert_warning :type => :warning,
:warning_type => "SQL Injection",
:message => /CVE-2012-2695/,
:confidence => 0,
:file => /Gemfile/
end
def test_sql_injection_scope_lambda def test_sql_injection_scope_lambda
assert_warning :type => :warning, assert_warning :type => :warning,
:warning_type => "SQL Injection", :warning_type => "SQL Injection",
......
...@@ -11,7 +11,7 @@ class RailsWithXssPluginTests < Test::Unit::TestCase ...@@ -11,7 +11,7 @@ class RailsWithXssPluginTests < Test::Unit::TestCase
:controller => 1, :controller => 1,
:model => 3, :model => 3,
:template => 1, :template => 1,
:warning => 12 } :warning => 13 }
end end
def report def report
...@@ -136,6 +136,14 @@ class RailsWithXssPluginTests < Test::Unit::TestCase ...@@ -136,6 +136,14 @@ class RailsWithXssPluginTests < Test::Unit::TestCase
:file => /Gemfile/ :file => /Gemfile/
end end
def test_rails_cve_2012_2695
assert_warning :type => :warning,
:warning_type => "SQL Injection",
:message => /CVE-2012-2695/,
:confidence => 0,
:file => /Gemfile/
end
def test_sql_injection_12 def test_sql_injection_12
assert_warning :type => :warning, assert_warning :type => :warning,
:warning_type => "SQL Injection", :warning_type => "SQL Injection",
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册