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

Remove SSL parameters from Redis connection logging to avoid exception #4532

Merged
merged 1 commit into from Apr 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions Changes.md
Expand Up @@ -2,6 +2,11 @@

[Sidekiq Changes](https://github.com/mperham/sidekiq/blob/master/Changes.md) | [Sidekiq Pro Changes](https://github.com/mperham/sidekiq/blob/master/Pro-Changes.md) | [Sidekiq Enterprise Changes](https://github.com/mperham/sidekiq/blob/master/Ent-Changes.md)

Unreleased
---------

- Avoid exception dumping SSL store in Redis connection logging [#4532]

6.0.7
---------

Expand Down
2 changes: 1 addition & 1 deletion lib/sidekiq/redis_connection.rb
Expand Up @@ -97,7 +97,7 @@ def log_info(options)
redacted = "REDACTED"

# deep clone so we can muck with these options all we want
scrubbed_options = Marshal.load(Marshal.dump(options))
scrubbed_options = Marshal.load(Marshal.dump(options.except(:ssl_params)))
if scrubbed_options[:url] && (uri = URI.parse(scrubbed_options[:url])) && uri.password
uri.password = redacted
scrubbed_options[:url] = uri.to_s
Expand Down
19 changes: 17 additions & 2 deletions test/test_redis_connection.rb
Expand Up @@ -197,8 +197,8 @@ def server_connection(*args)
{ host: 'host1', port: 26379, password: 'secret'},
{ host: 'host2', port: 26379, password: 'secret'},
{ host: 'host3', port: 26379, password: 'secret'},
],
password: 'secret'
],
password: 'secret'
}

output = capture_logging do
Expand All @@ -211,6 +211,21 @@ def server_connection(*args)
assert_includes(output, ':host=>"host3", :port=>26379, :password=>"REDACTED"')
assert_includes(output, ':password=>"REDACTED"')
end

it 'prunes SSL parameters from the logging' do
options = {
ssl_params: {
cert_store: OpenSSL::X509::Store.new
}
}

output = capture_logging do
Sidekiq::RedisConnection.create(options)
end

assert_includes(options.inspect, "ssl_params")
refute_includes(output, "ssl_params")
end
end
end

Expand Down