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

esrally must not log clear text user passwords #464

Merged
merged 3 commits into from
Apr 10, 2018
Merged

esrally must not log clear text user passwords #464

merged 3 commits into from
Apr 10, 2018

Conversation

suckowbiz
Copy link
Contributor

@suckowbiz suckowbiz commented Apr 10, 2018

esrally 0.9.4 logs the basic auth password in clear text:

2018-04-08 07:00:00,100 PID:42 rally.client INFO Creating ES client connected to [{'host': '1.2.3.4', 'port': 9200}, {'host': '1.2.3.5', 'port': 9200}] with options [{'use_ssl': True, 'verify_certs': False, 'basic_auth_user': 'me', 'basic_auth_password': 'mypassword', 'http_auth': ('me', 'password')}]

esrally must not do this to enable usage in enterprise environments.

Please accept PR (following).

Copy link
Member

@danielmitterdorfer danielmitterdorfer left a comment

Choose a reason for hiding this comment

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

Thank you for the PR! I left a couple of comments.

@@ -12,7 +12,12 @@ class EsClientFactory:
Abstracts how the Elasticsearch client is created. Intended for testing.
"""
def __init__(self, hosts, client_options):
logger.info("Creating ES client connected to %s with options [%s]" % (hosts, client_options))
masked_client_options = dict(client_options)
if masked_client_options.has_key("basic_auth_password"):
Copy link
Member

Choose a reason for hiding this comment

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

Can you please change this to "basic_auth_password" in masked_client_options?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes. I learned it's more pyhtonic and Pyhton 3 compatible: https://stackoverflow.com/questions/1323410/has-key-or-in

masked_client_options = dict(client_options)
if masked_client_options.has_key("basic_auth_password"):
masked_client_options["basic_auth_password"] = "*****"
if masked_client_options.has_key("http_auth"):
Copy link
Member

Choose a reason for hiding this comment

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

Can you please change this to "http_auth" in masked_client_options?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will do.

if masked_client_options.has_key("basic_auth_password"):
masked_client_options["basic_auth_password"] = "*****"
if masked_client_options.has_key("http_auth"):
masked_client_options["http_auth"] = (client_options["basic_auth_user"], "*****")
Copy link
Member

Choose a reason for hiding this comment

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

I think this should be masked_client_options["http_auth"] = (client_options["http_auth"][0], "*****") as you are modifying the http_auth entry and a basic_auth_user does not necessarily exist then.

@danielmitterdorfer danielmitterdorfer added enhancement Improves the status quo :Metrics How metrics are stored, calculated or aggregated :Load Driver Changes that affect the core of the load driver such as scheduling, the measurement approach etc. labels Apr 10, 2018
Copy link
Contributor

@dliappis dliappis left a comment

Choose a reason for hiding this comment

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

Thanks! Left one minor comment.

masked_client_options["basic_auth_password"] = "*****"
if masked_client_options.has_key("http_auth"):
masked_client_options["http_auth"] = (client_options["basic_auth_user"], "*****")
logger.info("Creating ES client connected to %s with options [%s]" % (hosts, masked_client_options))
Copy link
Contributor

Choose a reason for hiding this comment

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

Very minor comment/ask, the current code is not consistent at the moment, but while you are at it, would it be possible to use the comma format and have the options as arguments, as documented here? The idea is that moving forwards we move away from % for strings, so in your case it'd be:

logger.info("Creating ES client connected to %s with options [%s]", hosts, masked_client_options)

Thank you!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Of course.

@suckowbiz
Copy link
Contributor Author

Thanks for the review. I applied the requested changes.

@danielmitterdorfer
Copy link
Member

Thanks for your contribution and iterating on the PR! The changes looks fine to me.

We'll merge the PR soon. It will be included in the next release 0.10.0 of Rally.

@danielmitterdorfer danielmitterdorfer added this to the 0.10.0 milestone Apr 10, 2018
@suckowbiz
Copy link
Contributor Author

Thanks for accepting my commit. Looking forward to run 0.10.0 soonish :).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Improves the status quo :Load Driver Changes that affect the core of the load driver such as scheduling, the measurement approach etc. :Metrics How metrics are stored, calculated or aggregated
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants