-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Redact URLs before logging or returning in error #2643
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this looks good, but we need a test I think on this one.
I looked at the time but didn't see any framework for testing the logged strings sanely, so I passed on it. I can do tests for the auxiliary helpers but that's not E2E so only tests that redaction works. |
@kozlovic may be able to assist, he has a dummy logger for checking that certain things get logged etc. |
@philpennock Here is an example on how to use a logger that capture debug statements: nats-server/server/mqtt_test.go Line 5271 in 208146a
|
60ad149
to
e70f3c0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not totally against the idea of moving one of the logger to a central place. Still, I have some comments that I think could be applied regardless of moving logger or creating simple ones.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. For the t.Errorf(), I personally think that they are not required and we should always use t.Fatalf(). Errorf() is ok if you want to list all possible issues, but again, as part of dev when fixing the issue(s), but once finalized, there is no point in having it. But this is not a blocker, more of a personal preference.
452320e
to
e320be4
Compare
squashed down to 3 commits with distinct changes, and rebased to current main. Still need to sort out the solicited gone/back test scenario, but Ivan has provided me with guidance on triggering that; once that's in, we'll be good. |
This does not affect strings which failed to parse, and in such a scenario there's a mix of "which evil" to accept; we can't sanely find what should be redacted in those cases, so we leave them alone for debugging. The JWT library returns some errors for Operator URLs, but it rejects URLs which contain userinfo, so there can't be passwords in those and they're safe. Fixes #2597
Create internal/testhelper and move DummyLogger there, so it can be used from the test/ sub-dir too. Let DummyLogger optionally accumulate all log messages, not just retain the last-seen message. Confirm no passwords logged by TestLeafNodeBasicAuthFailover. Change TestNoPasswordsFromConnectTrace to check all trace messages, not just the most recent. Validate existing trace redaction in TestRouteToSelf.
e320be4
to
468cc13
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
This does not affect strings which failed to parse, and in such a scenario there's a mix of "which evil" to accept; we can't sanely find what should be redacted in those cases, so we leave them alone for debugging.
The JWT library returns some errors for Operator URLs, but it rejects URLs which contain userinfo, so there can't be passwords in those and they're safe.
Fixes #2597
/cc @nats-io/core