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.4.2 lib/one_apm/support/parameter_filtering.rb
oneapm_rpm-1.4.1 lib/one_apm/support/parameter_filtering.rb
oneapm_rpm-1.4.0 lib/one_apm/support/parameter_filtering.rb
oneapm_rpm-1.3.7 lib/one_apm/support/parameter_filtering.rb
oneapm_rpm-1.3.7.rc1 lib/one_apm/support/parameter_filtering.rb
oneapm_rpm-1.3.6 lib/one_apm/support/parameter_filtering.rb
oneapm_rpm-1.3.6.rc1 lib/one_apm/support/parameter_filtering.rb
oneapm_rpm-1.3.5 lib/one_apm/support/parameter_filtering.rb
oneapm_rpm-1.3.5.rc1 lib/one_apm/support/parameter_filtering.rb
oneapm_rpm-1.3.4 lib/one_apm/support/parameter_filtering.rb
oneapm_rpm-1.3.4.rc1 lib/one_apm/support/parameter_filtering.rb
oneapm_rpm-1.3.3 lib/one_apm/support/parameter_filtering.rb
oneapm_rpm-1.3.3.rc1 lib/one_apm/support/parameter_filtering.rb
oneapm_rpm-1.3.2 lib/one_apm/support/parameter_filtering.rb
oneapm_rpm-1.3.2.rc1 lib/one_apm/support/parameter_filtering.rb
oneapm_rpm-1.3.1 lib/one_apm/support/parameter_filtering.rb
oneapm_rpm-1.3.1.rc1 lib/one_apm/support/parameter_filtering.rb
oneapm_rpm-1.3.0 lib/one_apm/support/parameter_filtering.rb
oneapm_rpm-1.3.0.rc1 lib/one_apm/support/parameter_filtering.rb
oneapm_rpm-1.2.9 lib/one_apm/support/parameter_filtering.rb