-
Notifications
You must be signed in to change notification settings - Fork 156
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 api and app keys from errors #124
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.
Kudos for taking this on!
request.go
Outdated
func (client *Client) doJsonRequest(method, api string, | ||
reqbody, out interface{}) error { | ||
err := client.doJsonRequestUnsafe(method, api, reqbody, out) |
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.
A nit picking alternative would be:
if err := client.doJsonRequestUnsafe(method, api, reqbody, out) ; err != nil {
errString := strings.Replace(err.Error(), client.apiKey, "redacted", -1)
errString = strings.Replace(errString, client.appKey, "redacted", -1)
return fmt.Errorf(errString)
}
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.
Will update this ^
request.go
Outdated
|
||
// doJsonRequestUnsafe is the simplest type of request: a method on a URI that returns | ||
// some JSON result which we unmarshal into the passed interface. | ||
func (client *Client) doJsonRequestUnsafe(method, api string, |
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.
Would doJsonRequestUnredacted
be a more informative name?
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 know this works, but it would be awesome to have a test to make sure there is no regression later on.
* Unset api / app keys resulted in redacted being inserted between each letter of the error string. This will ensure only actually set (rather than empty string) api / app keys are redacted.
Rebased off master to resolve conflicts, also added the tests you mentioned @ojongerius. What do you think? :) |
Awesome, thanks for adding the tests! LGTM! |
Fix #76.
I don't know if this is the right way to fix this but I took a stab at it.