-
Notifications
You must be signed in to change notification settings - Fork 206
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
Remove dangerous format specifiers #1566
Conversation
@@ -112,7 +112,13 @@ func TestOwnerNotFound_RemembersCause(t *testing.T) { | |||
|
|||
g.Expect(errors.Cause(err)).To(Equal(cause)) | |||
|
|||
fmtedErr := fmt.Sprintf("%+v", err) | |||
var builder strings.Builder | |||
for err != nil { |
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 don't think this loop is necessary - the wrapper error should include the context of the errors it wraps. The stacktrace that's needed for the error line assertions can be retrieved using this technique.
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.
The ReferenceNotFound
error wasn't including the nested context, but now it does. I'll query the stack trace separately.
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.
Done.
Codecov Report
@@ Coverage Diff @@
## master #1566 +/- ##
==========================================
- Coverage 63.48% 63.41% -0.07%
==========================================
Files 178 178
Lines 11739 11739
==========================================
- Hits 7452 7444 -8
- Misses 3620 3628 +8
Partials 667 667
Continue to review full report at Codecov.
|
|
||
// stackTracer allows access to the stack trace of an error | ||
// This should be exposed by the errors package, but it is not | ||
type stackTracer interface { |
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.
It would make more sense to define this in the test since it's the only place that's using it.
What this PR does / why we need it:
Removes all uses of the format specifiers
%v
and%+v
as those dump entire objects into the log, which very likely will include secrets (e.g. credentials etc); we don't want those exposed in the logs.Closes #1470
Special notes for your reviewer:
How does this PR make you feel:
![gif](https://camo.githubusercontent.com/df57dd66a684f364b1b7ca8e7c083c37fb2ae265c94f131c4dab3e9793afbaa0/68747470733a2f2f6d656469612e67697068792e636f6d2f6d656469612f316b303344576173396266625963626233332f67697068792e676966)