Created
June 9, 2021 10:52
-
-
Save rslhdyt/12f62f5c144c60d452b7e406bcf46b33 to your computer and use it in GitHub Desktop.
Manually filter parameters or hash based on filter parameter logging config in ruby on rails application
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Be sure to restart your server when you modify this file. | |
# Configure sensitive parameters which will be filtered from the log file. | |
Rails.application.config.filter_parameters += %i[ | |
passw password vendorable_id | |
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
filters = Rails.application.config.filter_parameters | |
params = { | |
name: 'banana', | |
vendorable_id: 'secret' | |
} | |
f = ActiveSupport::ParameterFilter.new filters | |
f.filter params | |
# {name: 'banana', vendorable_id: [Filtered]} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment