Sha256: 0e4b97db40ab359cf77c44344e38323b03c684d11995694c2c73770a78890217

Contents?: true

Size: 861 Bytes

Versions: 102

Compression:

Stored size: 861 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"),
        :user_input => input,
        :confidence => confidence
    end
  end
end

Version data entries

102 entries across 88 versions & 4 rubygems

Version Path
brakeman-5.2.3 lib/brakeman/checks/check_session_manipulation.rb
brakeman-lib-5.2.3 lib/brakeman/checks/check_session_manipulation.rb
brakeman-min-5.2.3 lib/brakeman/checks/check_session_manipulation.rb
brakeman-5.2.2 lib/brakeman/checks/check_session_manipulation.rb
brakeman-lib-5.2.2 lib/brakeman/checks/check_session_manipulation.rb
brakeman-min-5.2.2 lib/brakeman/checks/check_session_manipulation.rb
brakeman-5.2.1 lib/brakeman/checks/check_session_manipulation.rb
brakeman-lib-5.2.1 lib/brakeman/checks/check_session_manipulation.rb
brakeman-min-5.2.1 lib/brakeman/checks/check_session_manipulation.rb
brakeman-5.2.0 lib/brakeman/checks/check_session_manipulation.rb
brakeman-lib-5.2.0 lib/brakeman/checks/check_session_manipulation.rb
brakeman-min-5.2.0 lib/brakeman/checks/check_session_manipulation.rb
brakeman-5.1.2 lib/brakeman/checks/check_session_manipulation.rb
brakeman-lib-5.1.2 lib/brakeman/checks/check_session_manipulation.rb
brakeman-min-5.1.2 lib/brakeman/checks/check_session_manipulation.rb
brakeman-5.1.1 lib/brakeman/checks/check_session_manipulation.rb
brakeman-lib-5.1.1 lib/brakeman/checks/check_session_manipulation.rb
brakeman-min-5.1.1 lib/brakeman/checks/check_session_manipulation.rb
brakeman-5.1.0 lib/brakeman/checks/check_session_manipulation.rb
brakeman-lib-5.1.0 lib/brakeman/checks/check_session_manipulation.rb