Module: NewRelic::Agent::ParameterFiltering

Extended by:
ParameterFiltering
Included in:
ParameterFiltering
Defined in:
lib/new_relic/agent/parameter_filtering.rb

Instance Method Summary collapse

Instance Method Details

#apply_filters(env, params) ⇒ Object



28
29
30
31
32
33
34
# File 'lib/new_relic/agent/parameter_filtering.rb', line 28

def apply_filters(env, params)
  if filters = env[ACTION_DISPATCH_PARAMETER_FILTER]
    params = filter_using_rails(params, filters)
  end
  params = filter_rack_file_data(env, params)
  params
end

#filter_rack_file_data(env, params) ⇒ Object



43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/new_relic/agent/parameter_filtering.rb', line 43

def filter_rack_file_data(env, params)
  content_type = env['CONTENT_TYPE']
  multipart = 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

#filter_rails_request_parameters(params) ⇒ Object



57
58
59
60
61
62
# File 'lib/new_relic/agent/parameter_filtering.rb', line 57

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

#filter_using_rails(params, filters) ⇒ Object



36
37
38
39
40
41
# File 'lib/new_relic/agent/parameter_filtering.rb', line 36

def filter_using_rails(params, filters)
  return params unless rails_filter_class?

  pre_filtered_params = filter_rails_request_parameters(params)
  RAILS_FILTER_CLASS.new(filters).filter(pre_filtered_params)
end