Skip to content

Commit

Permalink
Merge pull request rails#44388 from p8/guides/filter-parameters-default
Browse files Browse the repository at this point in the history
Update parameter filter logging guides [ci-skip]
  • Loading branch information
kamipo committed Feb 10, 2022
2 parents b961af3 + e3beba1 commit e42e60e
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 5 deletions.
10 changes: 8 additions & 2 deletions guides/source/action_controller_overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -1166,13 +1166,19 @@ Rails keeps a log file for each environment in the `log` folder. These are extre

### Parameters Filtering

You can filter out sensitive request parameters from your log files by appending them to `config.filter_parameters` in the application configuration. These parameters will be marked [FILTERED] in the log.
You can filter out sensitive request parameters from your log files by
appending them to `config.filter_parameters` in the application configuration.
These parameters will be marked [FILTERED] in the log.

```ruby
config.filter_parameters << :password
```

NOTE: Provided parameters will be filtered out by partial matching regular expression. Rails adds default `:password` in the appropriate initializer (`initializers/filter_parameter_logging.rb`) and cares about typical application parameters `password` and `password_confirmation`.
NOTE: Provided parameters will be filtered out by partial matching regular
expression. Rails adds a list of default filters, including `:passw`,
`:secret`, and `:token`, in the appropriate
initializer(`initializers/filter_parameter_logging.rb`), to handle typical
application parameters like `password`, `password_confirmation` and `my_token`.

### Redirects Filtering

Expand Down
15 changes: 13 additions & 2 deletions guides/source/configuring.md
Original file line number Diff line number Diff line change
Expand Up @@ -247,8 +247,19 @@ Is the class used to detect file updates in the file system when `config.reload_

#### `config.filter_parameters`

Used for filtering out the parameters that you don't want shown in the logs, such as passwords or credit card
numbers. It also filters out sensitive values of database columns when calling `#inspect` on an Active Record object. By default, Rails filters out passwords by adding `Rails.application.config.filter_parameters += [:password]` in `config/initializers/filter_parameter_logging.rb`. Parameters filter works by partial matching regular expression.
Used for filtering out the parameters that you don't want shown in the logs,
such as passwords or credit card numbers. It also filters out sensitive values
of database columns when calling `#inspect` on an Active Record object. By
default, Rails filters out passwords by adding the following filters in
`config/initializers/filter_parameter_logging.rb`.

```ruby
Rails.application.config.filter_parameters += [
:passw, :secret, :token, :_key, :crypt, :salt, :certificate, :otp, :ssn
]
```

Parameters filter works by partial matching regular expression.

#### `config.force_ssl`

Expand Down
6 changes: 5 additions & 1 deletion guides/source/security.md
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,11 @@ By default, Rails logs all requests being made to the web application. But log f
config.filter_parameters << :password
```

NOTE: Provided parameters will be filtered out by partial matching regular expression. Rails adds default `:password` in the appropriate initializer (`initializers/filter_parameter_logging.rb`) and cares about typical application parameters `password` and `password_confirmation`.
NOTE: Provided parameters will be filtered out by partial matching regular
expression. Rails adds a list of default filters, including `:passw`,
`:secret`, and `:token`, in the appropriate
initializer(`initializers/filter_parameter_logging.rb`), to handle typical
application parameters like `password`, `password_confirmation` and `my_token`.

### Regular Expressions

Expand Down

0 comments on commit e42e60e

Please sign in to comment.