Sha256: cdaf7f8923ecbf404b956a5f6201ca79999e88a292e2b8c01cc49042637d11e7

Contents?: true

Size: 893 Bytes

Versions: 3

Compression:

Stored size: 893 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 => msg(msg_input(input), " used as key in session hash"),
        :code => result[:call],
        :user_input => input,
        :confidence => confidence
    end
  end
end

Version data entries

3 entries across 3 versions & 3 rubygems

Version Path
brakeman-4.4.0 lib/brakeman/checks/check_session_manipulation.rb
brakeman-lib-4.4.0 lib/brakeman/checks/check_session_manipulation.rb
brakeman-min-4.4.0 lib/brakeman/checks/check_session_manipulation.rb