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

[Anonymize Question] Is there a way to anonymize url in Traceback? #517

Open
xiao623 opened this issue Sep 13, 2021 · 1 comment
Open

[Anonymize Question] Is there a way to anonymize url in Traceback? #517

xiao623 opened this issue Sep 13, 2021 · 1 comment

Comments

@xiao623
Copy link
Contributor

xiao623 commented Sep 13, 2021

I need to set https://<user>:<password>@xxxxx.com:9200 for my secured elasticsearch cluster and i also konw that we can use anonymize_url when calling logger.xxx().

However, I had found that the message <user>:<password> still could be known from the Traceback.

For Example,
https://github.com/chaoss/grimoirelab-elk/blob/5db69f80e0d436ccf9be2403ae1bf98529337545/grimoire_elk/elastic.py#L181-L182

 res = self.requests.put(url + '?refresh=true', data=bulk_json, headers=headers)
 res.raise_for_status()

Here, url would be https://<user>:<password>@xxxxx.com:9200.
But if there a wrong status_code in raise_for_status, the messge would be :
https://github.com/psf/requests/blob/1e5fad7433772b648fcbc921e2a79de5c4c6be8b/requests/models.py#L954

http_error_msg = u'%s Client Error: %s for url: %s' % (self.status_code, reason, self.url)

and raise HTTPError with self.url which contains the message <user>:<password>.

Like #309 (comment)
requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: https://XXX:[email protected]:9243/.kibana/doc/dashboard:Overview.

I had tried to use anonymize_url in the method feed_backend in elk.py but the message <user>:<password> still be shown in Traceback

https://github.com/chaoss/grimoirelab-elk/blob/5db69f80e0d436ccf9be2403ae1bf98529337545/grimoire_elk/elk.py#L178

-           error_msg = "Error feeding raw from {} ({}): {}".format(backend_name, backend.origin, ex)
+          error_msg = "Error feeding raw from {} ({}): {}".format(backend_name, backend.origin, anonymize_url(str(ex)))

@xiao623
Copy link
Contributor Author

xiao623 commented Sep 14, 2021

  • Is that exec_info=True necessary? Maybe we could remove it.
    logger.error("Error enriching raw {}".format(ex), exc_info=True)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants