Sha256: 34111fe1152d3e980e2940886f34ceb057c98b82aca40ab2aefed1a8e442c7b6

Contents?: true

Size: 973 Bytes

Versions: 42

Compression:

Stored size: 973 Bytes

Contents

# encoding: utf-8

module OneApm
  module Support
    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

42 entries across 42 versions & 1 rubygems

Version Path
oneapm_rpm-1.2.9.rc1 lib/one_apm/support/parameter_filtering.rb
oneapm_rpm-1.2.8 lib/one_apm/support/parameter_filtering.rb
oneapm_rpm-1.2.8.rc1 lib/one_apm/support/parameter_filtering.rb
oneapm_rpm-1.2.7 lib/one_apm/support/parameter_filtering.rb
oneapm_rpm-1.2.7.rc1 lib/one_apm/support/parameter_filtering.rb
oneapm_rpm-1.2.6 lib/one_apm/support/parameter_filtering.rb
oneapm_rpm-1.2.6.rc1 lib/one_apm/support/parameter_filtering.rb
oneapm_rpm-1.2.5 lib/one_apm/support/parameter_filtering.rb
oneapm_rpm-1.2.5.rc1 lib/one_apm/support/parameter_filtering.rb
oneapm_rpm-1.2.4 lib/one_apm/support/parameter_filtering.rb
oneapm_rpm-1.2.4.rc1 lib/one_apm/support/parameter_filtering.rb
oneapm_rpm-1.2.3 lib/one_apm/support/parameter_filtering.rb
oneapm_rpm-1.2.3.rc2 lib/one_apm/support/parameter_filtering.rb
oneapm_rpm-1.2.2 lib/one_apm/support/parameter_filtering.rb
oneapm_rpm-1.2.2.rc lib/one_apm/support/parameter_filtering.rb
oneapm_rpm-1.2.1 lib/one_apm/support/parameter_filtering.rb
oneapm_rpm-1.2.1.rc lib/one_apm/support/parameter_filtering.rb
oneapm_rpm-1.2.0 lib/one_apm/support/parameter_filtering.rb
oneapm_rpm-1.1.3 lib/one_apm/support/parameter_filtering.rb
oneapm_rpm-1.1.2 lib/one_apm/support/parameter_filtering.rb