Sha256: 910fc03867e3903e391b46030246f1d9683c69e0434bf83f8dff787713b255aa

Contents?: true

Size: 1.26 KB

Versions: 20

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

20 entries across 20 versions & 2 rubygems

Version Path
newrelic_rpm-3.17.2.327 lib/new_relic/agent/parameter_filtering.rb
newrelic_rpm-3.17.1.326 lib/new_relic/agent/parameter_filtering.rb
newrelic_rpm-3.17.0.325 lib/new_relic/agent/parameter_filtering.rb
newrelic_rpm-3.16.3.323 lib/new_relic/agent/parameter_filtering.rb
newrelic_rpm-3.16.2.321 lib/new_relic/agent/parameter_filtering.rb
newrelic_rpm-3.16.1.320 lib/new_relic/agent/parameter_filtering.rb
newrelic_rpm-3.16.0.318 lib/new_relic/agent/parameter_filtering.rb
ish_lib_manager-0.0.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/newrelic_rpm-3.15.2.317/lib/new_relic/agent/parameter_filtering.rb
newrelic_rpm-3.15.2.317 lib/new_relic/agent/parameter_filtering.rb
newrelic_rpm-3.15.1.316 lib/new_relic/agent/parameter_filtering.rb
newrelic_rpm-3.15.0.314 lib/new_relic/agent/parameter_filtering.rb
newrelic_rpm-3.14.3.313 lib/new_relic/agent/parameter_filtering.rb
newrelic_rpm-3.14.2.312 lib/new_relic/agent/parameter_filtering.rb
newrelic_rpm-3.14.1.311 lib/new_relic/agent/parameter_filtering.rb
newrelic_rpm-3.14.0.305 lib/new_relic/agent/parameter_filtering.rb
newrelic_rpm-3.13.2.302 lib/new_relic/agent/parameter_filtering.rb
newrelic_rpm-3.13.1.300 lib/new_relic/agent/parameter_filtering.rb
newrelic_rpm-3.13.0.299 lib/new_relic/agent/parameter_filtering.rb
newrelic_rpm-3.12.1.298 lib/new_relic/agent/parameter_filtering.rb
newrelic_rpm-3.12.0.288 lib/new_relic/agent/parameter_filtering.rb