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

Obfuscates ACL tokens appearing in /v1/acl/<verb>/<token> APIs. #3276

Merged
merged 3 commits into from
Jul 15, 2017

Conversation

slackpad
Copy link
Contributor

@slackpad slackpad commented Jul 15, 2017

Here's how this looks after the change, note that the URL-based tokens are now redacted, too:

    2017/07/14 21:23:47 [DEBUG] http: Request GET /v1/acl/list?dc=dc1&token=<hidden> (149.11µs) from=127.0.0.1:56380
    2017/07/14 21:23:52 [DEBUG] http: Request GET /v1/acl/info/<hidden>?dc=dc1&token=<hidden> (109.113µs) from=127.0.0.1:56380
    2017/07/14 21:23:57 [DEBUG] http: Request GET /v1/acl/info/<hidden>?dc=dc1&token=<hidden> (62.042µs) from=127.0.0.1:56380
    2017/07/14 21:24:02 [DEBUG] http: Request PUT /v1/acl/clone/<hidden>?dc=dc1&token=<hidden> (281.945µs) from=127.0.0.1:56380
    2017/07/14 21:24:02 [DEBUG] http: Request GET /v1/acl/list?dc=dc1&token=<hidden> (105.715µs) from=127.0.0.1:56380
    2017/07/14 21:24:02 [DEBUG] http: Request GET /v1/acl/info/<hidden>?dc=dc1&token=<hidden> (90.201µs) from=127.0.0.1:56380
    2017/07/14 21:24:54 [DEBUG] http: Request PUT /v1/acl/destroy/<hidden>?dc=dc1&token=<hidden> (237.591µs) from=127.0.0.1:56380

@slackpad slackpad changed the title Obfuscates ACL tokens appearing in /v1/acl APIs. Obfuscates ACL tokens appearing in /v1/acl/<verb>/<token> APIs. Jul 15, 2017
@@ -166,6 +167,12 @@ func (s *HTTPServer) handler(enableDebug bool) http.Handler {
return mux
}

// aclEndpointRE is used to find old ACL endpoints that take tokens in the URL
Copy link
Contributor

Choose a reason for hiding this comment

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

I think the RE is too clever. I've read this a couple of times now and it isn't clear to me what it is trying to achieve. You could try to use multiple REs or at least provide some examples of what this is supposed to match. Since you're trying to obfuscate sensitive data I'd say clarity goes before efficiency. Maybe don't use an RE at all and work with url.Parse or strings.Split.

a.srv.wrap(handler)(resp, req)

// Make sure no tokens from the URL show up in the log
if strings.Contains(buf.String(), "secret") {
Copy link
Contributor

Choose a reason for hiding this comment

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

buf.String() allocs twice here. Not relevant for the test but don't leave a bad example. Also, don't you need to reset the buffer between test runs? Probably not that important here. secret should never show up.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The buffer will accumulate. I changed this to look for a specific string in the buffer, which is a lot safer. Also fixed the double string call.

@slackpad slackpad merged commit 218ac4c into master Jul 15, 2017
@slackpad slackpad deleted the obfuscate-url branch July 15, 2017 07:07
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