Sha256: f0fb7dd8d078949e630519e1ea5da8cd0b305d50bccb1710ea707ac9a6f5816c

Contents?: true

Size: 907 Bytes

Versions: 25

Compression:

Stored size: 907 Bytes

Contents

require 'brakeman/checks/base_check'

class Brakeman::CheckSessionManipulation < Brakeman::BaseCheck
  Brakeman::Checks.add self

  @description = "Check for user input in session keys"

  def run_check
    tracker.find_call(:method => :[]=, :target => :session).each do |result|
      process_result result
    end
  end

  def process_result result
    return unless original? result

    index = result[:call].first_arg

    if input = has_immediate_user_input?(index)
      if params? index
        confidence = :high
      else
        confidence = :medium
      end

      warn :result => result,
        :warning_type => "Session Manipulation",
        :warning_code => :session_key_manipulation,
        :message => "#{friendly_type_of(input).capitalize} used as key in session hash",
        :code => result[:call],
        :user_input => input,
        :confidence => confidence
    end
  end
end

Version data entries

25 entries across 25 versions & 3 rubygems

Version Path
brakeman-lib-4.0.1 lib/brakeman/checks/check_session_manipulation.rb
brakeman-4.0.1.pre1 lib/brakeman/checks/check_session_manipulation.rb
brakeman-4.0.0 lib/brakeman/checks/check_session_manipulation.rb
brakeman-min-4.0.0 lib/brakeman/checks/check_session_manipulation.rb
brakeman-lib-4.0.0 lib/brakeman/checks/check_session_manipulation.rb