mirror of
https://github.com/basecamp/once-campfire.git
synced 2026-09-22 16:24:54 +09:00
Redact bot key from request logs (#269)
The bot HTTP API carries the bot key as a URL path segment (/rooms/:room_id/:bot_key/...). config.filter_parameters redacts query and form parameters but never path segments, so the key was written verbatim to the request log (the "Started POST ..." line) and to any log line echoing the pagination Link header. Add a log formatter that redacts the bot-key path segment wherever it appears in a formatted line, and wire it into the production logger.
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
require "active_support/core_ext/integer/time"
|
||||
require "active_support/core_ext/numeric/bytes"
|
||||
require_relative "../../lib/rails_ext/log_scrubbing_formatter"
|
||||
|
||||
Rails.application.configure do
|
||||
# Settings specified here will take precedence over those in config/application.rb.
|
||||
@@ -50,7 +51,7 @@ Rails.application.configure do
|
||||
|
||||
# Log to STDOUT by default
|
||||
config.logger = ActiveSupport::Logger.new(STDOUT)
|
||||
.tap { |logger| logger.formatter = ::Logger::Formatter.new }
|
||||
.tap { |logger| logger.formatter = LogScrubbingFormatter.new }
|
||||
.then { |logger| ActiveSupport::TaggedLogging.new(logger) }
|
||||
|
||||
# Prepend all log lines with the following tags.
|
||||
|
||||
Reference in New Issue
Block a user