Sha256: 851a0e4ef64f25a6c5a245640f63a3148275b1c2cad099d77fdbeadd94438a02

Contents?: true

Size: 1.09 KB

Versions: 4

Compression:

Stored size: 1.09 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
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
newrelic_rpm-3.11.2.286 lib/new_relic/agent/parameter_filtering.rb
newrelic_rpm-3.11.1.284 lib/new_relic/agent/parameter_filtering.rb
newrelic_rpm-3.11.0.283 lib/new_relic/agent/parameter_filtering.rb
newrelic_rpm-3.10.0.279 lib/new_relic/agent/parameter_filtering.rb