Sha256: 6d45c69f6acd1eabcbb4f83c73bb75a56f5231ac2014aba21b549edc45617484

Contents?: true

Size: 1016 Bytes

Versions: 19

Compression:

Stored size: 1016 Bytes

Contents

# encoding: utf-8
# This file is distributed under New Relic's license terms.
# See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details.

require 'erb'

module NewRelic
  module Agent
    module BrowserToken

      def self.get_token(request)
        return nil unless request

        agent_flag = request.cookies['NRAGENT']
        if agent_flag and agent_flag.instance_of? String
          s = agent_flag.split("=")
          if s.length == 2
            if s[0] == "tk" && s[1]
              ERB::Util.h(sanitize_token(s[1]))
            end
          end
        else
          nil
        end
      end

      # Run through a collection of unsafe characters ( in the context of the token )
      # and set the token to an empty string if any of them are found in the token so that
      # potential XSS attacks via the token are avoided
      def self.sanitize_token(token)
        if ( /[<>'"]/ =~ token )
          token.replace("")
        end
        token
      end
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
newrelic_rpm-3.9.0.229 lib/new_relic/agent/browser_token.rb
newrelic_rpm-3.8.1.221 lib/new_relic/agent/browser_token.rb
newrelic_rpm-3.8.0.218 lib/new_relic/agent/browser_token.rb
newrelic_rpm-3.7.3.204 lib/new_relic/agent/browser_token.rb
newrelic_rpm-3.7.3.199 lib/new_relic/agent/browser_token.rb
newrelic_rpm-3.7.2.195 lib/new_relic/agent/browser_token.rb
newrelic_rpm-3.7.2.192 lib/new_relic/agent/browser_token.rb
newrelic_rpm-3.7.2.190.beta lib/new_relic/agent/browser_token.rb
newrelic_rpm-3.7.1.188 lib/new_relic/agent/browser_token.rb
newrelic_rpm-3.7.1.182 lib/new_relic/agent/browser_token.rb
newrelic_rpm-3.7.1.180 lib/new_relic/agent/browser_token.rb
newrelic_rpm-3.7.0.177 lib/new_relic/agent/browser_token.rb
newrelic_rpm-3.7.0.174.beta lib/new_relic/agent/browser_token.rb
newrelic_rpm-3.6.9.171 lib/new_relic/agent/browser_token.rb
newrelic_rpm-3.6.8.168 lib/new_relic/agent/browser_token.rb
newrelic_rpm-3.6.8.164 lib/new_relic/agent/browser_token.rb
newrelic_rpm-3.6.7.159 lib/new_relic/agent/browser_token.rb
newrelic_rpm-3.6.7.159.beta lib/new_relic/agent/browser_token.rb
newrelic_rpm-3.6.7.152 lib/new_relic/agent/browser_token.rb