Skip to content

RUBY-1021 Use Redacted options class to redact option fields when printing #687

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

Merged
merged 15 commits into from
Sep 10, 2015

Conversation

estolfo
Copy link
Contributor

@estolfo estolfo commented Sep 2, 2015

No description provided.

@estolfo estolfo changed the title [WIP] RUBY-1021 Use SensitiveOptions class to redact option fields when printing [WIP] RUBY-1021 Use Redacted options class to redact option fields when printing Sep 2, 2015
@estolfo estolfo force-pushed the RUBY-1021-sensitive-opts branch from be8babf to be3eaaf Compare September 8, 2015 19:15
@estolfo estolfo changed the title [WIP] RUBY-1021 Use Redacted options class to redact option fields when printing RUBY-1021 Use Redacted options class to redact option fields when printing Sep 8, 2015
@durran
Copy link
Member

durran commented Sep 9, 2015

I envisioned that we would only need to do this in places where the user provides the options, such as:

Mongo::Client#initialize
Mongo::Client#with

And methods like merge need to be implemented in order to not have to wrap every time we call merge in our codebase. Also, methods with signatures such as:

method_name(options = {}) should be changed to method_name(options = Options::Redacted.new)

@estolfo
Copy link
Contributor Author

estolfo commented Sep 9, 2015

ok @durran, I've made all the suggested changes. Let me know if it looks good.

EDIT: I'm actually not convinced this is a good solution. I've realized after testing on jenkins that ssl doesn't work because ssl_options eventually becomes a hash with string keys. I can implement #reject on Options::Redacted to avoid this but it still seems like this is, in general, a fragile solution.
(This line shows why it becomes a hash with string keys: https://github.com/mongodb/mongo-ruby-driver/blob/master/lib/mongo/server/connection.rb#L151 )

@estolfo estolfo force-pushed the RUBY-1021-sensitive-opts branch 2 times, most recently from 030c120 to ffa6d15 Compare September 10, 2015 15:37
def reject!
if block_given?
n_keys = keys.size
self.keys.each do |key|
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't need the self in front of anything but the self[key] and the direct reference.

@estolfo estolfo force-pushed the RUBY-1021-sensitive-opts branch from 2474f21 to 42b6283 Compare September 10, 2015 17:47
estolfo added a commit that referenced this pull request Sep 10, 2015
RUBY-1021 Use Redacted options class to redact option fields when printing
@estolfo estolfo merged commit a22acc1 into mongodb:master Sep 10, 2015
@estolfo estolfo deleted the RUBY-1021-sensitive-opts branch October 26, 2015 15:32
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

Successfully merging this pull request may close these issues.

2 participants