Sha256: c250e275cea9ce366a7cdfb246638bd8642ae28af69a409ae568c3fd00201633

Contents?: true

Size: 1.04 KB

Versions: 10

Compression:

Stored size: 1.04 KB

Contents

require 'brakeman/checks/base_check'

#Check for vulnerability in nested attributes in Rails 2.3.9 and 3.0.0
#http://groups.google.com/group/rubyonrails-security/browse_thread/thread/f9f913d328dafe0c
class Brakeman::CheckNestedAttributes < Brakeman::BaseCheck
  Brakeman::Checks.add self

  @description = "Checks for nested attributes vulnerability in Rails 2.3.9 and 3.0.0"

  def run_check
    version = tracker.config[:rails_version]

    if (version == "2.3.9" or version == "3.0.0") and uses_nested_attributes?
      message = "Vulnerability in nested attributes (CVE-2010-3933). Upgrade to Rails version "

      if version == "2.3.9"
        message << "2.3.10"
      else
        message << "3.0.1"
      end

      warn :warning_type => "Nested Attributes",
        :message => message,
        :confidence => CONFIDENCE[:high],
        :file => gemfile_or_environment
    end
  end

  def uses_nested_attributes?
    tracker.models.each do |name, model|
      return true if model[:options][:accepts_nested_attributes_for]
    end

    false
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
brakeman-1.6.2 lib/brakeman/checks/check_nested_attributes.rb
brakeman-1.6.1 lib/brakeman/checks/check_nested_attributes.rb
brakeman-1.6.0 lib/brakeman/checks/check_nested_attributes.rb
brakeman-1.6.0.pre1 lib/brakeman/checks/check_nested_attributes.rb
brakeman-1.5.3 lib/brakeman/checks/check_nested_attributes.rb
brakeman-1.5.2 lib/brakeman/checks/check_nested_attributes.rb
brakeman-1.5.1 lib/brakeman/checks/check_nested_attributes.rb
brakeman-1.5.0 lib/brakeman/checks/check_nested_attributes.rb
brakeman-1.4.0 lib/brakeman/checks/check_nested_attributes.rb
brakeman-1.3.0 lib/brakeman/checks/check_nested_attributes.rb