Sha256: 07e7a23137a65abe60d28927b10aeebfc61a0073392976de43c131e22ef8c9f8

Contents?: true

Size: 1.26 KB

Versions: 23

Compression:

Stored size: 1.26 KB

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.

module NewRelic
  module Agent
    module ParameterFiltering
      extend self

      def apply_filters(env, params)
        params = filter_using_rails(env, params)
        params = filter_rack_file_data(env, params)
        params
      end

      def filter_using_rails(env, params)
        return params unless defined?(ActionDispatch::Http::ParameterFilter) && env.key?("action_dispatch.parameter_filter")
        filters = env["action_dispatch.parameter_filter"]
        ActionDispatch::Http::ParameterFilter.new(filters).filter(params)
      end

      def filter_rack_file_data(env, params)
        content_type = env["CONTENT_TYPE"]
        multipart = content_type && content_type.start_with?("multipart")

        params.inject({}) do |memo, (k,v)|
          if multipart && v.is_a?(Hash) && v[:tempfile]
            memo[k] = "[FILE]"
          else
            memo[k] = v
          end
          memo
        end
      end

      def filter_rails_request_parameters(params)
        result = params.dup
        result.delete("controller")
        result.delete("action")
        result
      end
    end
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
newrelic_rpm-6.2.0.354 lib/new_relic/agent/parameter_filtering.rb
newrelic_rpm-6.1.0.352 lib/new_relic/agent/parameter_filtering.rb
newrelic_rpm-6.0.0.351 lib/new_relic/agent/parameter_filtering.rb
newrelic_rpm-5.7.0.350 lib/new_relic/agent/parameter_filtering.rb
newrelic_rpm-5.6.0.349 lib/new_relic/agent/parameter_filtering.rb
newrelic_rpm-5.5.0.348 lib/new_relic/agent/parameter_filtering.rb
newrelic_rpm-5.4.0.347 lib/new_relic/agent/parameter_filtering.rb
newrelic_rpm-5.3.0.346 lib/new_relic/agent/parameter_filtering.rb
newrelic_rpm-5.2.0.345 lib/new_relic/agent/parameter_filtering.rb
newrelic_rpm-5.1.0.344 lib/new_relic/agent/parameter_filtering.rb
newrelic_rpm-5.0.0.342 lib/new_relic/agent/parameter_filtering.rb
newrelic_rpm-4.8.0.341 lib/new_relic/agent/parameter_filtering.rb
newrelic_rpm-4.7.1.340 lib/new_relic/agent/parameter_filtering.rb
newrelic_rpm-4.7.0.339 lib/new_relic/agent/parameter_filtering.rb
newrelic_rpm-4.6.0.338 lib/new_relic/agent/parameter_filtering.rb
newrelic_rpm-4.5.0.337 lib/new_relic/agent/parameter_filtering.rb
newrelic_rpm-4.4.0.336 lib/new_relic/agent/parameter_filtering.rb
newrelic_rpm-4.3.0.335 lib/new_relic/agent/parameter_filtering.rb
newrelic_rpm-4.2.0.334 lib/new_relic/agent/parameter_filtering.rb
newrelic_rpm-4.1.0.333 lib/new_relic/agent/parameter_filtering.rb