Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Rails] Filter parameters not applied in logs #153

Open
jonian opened this issue Dec 11, 2018 · 1 comment
Open

[Rails] Filter parameters not applied in logs #153

jonian opened this issue Dec 11, 2018 · 1 comment

Comments

@jonian
Copy link

jonian commented Dec 11, 2018

Parameter filtering not applied in Rails applications. Using the code below fixes the issue:

def log_inspect
  info = mirror.log_informations
  info[:effective_url] = filter_url_params(info[:effective_url])

  "EASY #{info.map{|k, v| "#{k}=#{v}"}.flatten.join(' ')}"
end

def filter_url_params(url)
  return url unless Loggable.rails_logger

  filters = Rails.application.config.filter_parameters
  filters = ActionDispatch::Http::ParameterFilter.new(filters)

  uri = URI.parse(url)
  uri.query = filters.filter(CGI.parse(uri.query)).to_query

  CGI.unescape(uri.to_s)
end

Should I submit a PR?

@PericlesTheo
Copy link
Member

That would be great. Does it have to be tied to Rails though? Could we instead have some logic that one can register as a config any filtered params (for simplicity purposes they can only be a string or symbol to begin with) and have the logic to remove them here without the Rails dependency?

Thoughts?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants