-
Notifications
You must be signed in to change notification settings - Fork 781
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
toJSON and toJSONPretty messes up secret from Vault #1430
Comments
Thanks for filing the issue @nagypeterjob. To quickly restart the issue to be sure... the problem is the I can see this as an issue, but I'm not sure if just changing toJSON and toJSONPretty would work as it seems like this could break things. Maybe an option can be worked in somehow. I'm going to label this an enhancement for now assuming we'll need to add some way to enable this (vs. changing existing behavior). Feel free to chime in if you have a differing opinion or some ideas on the implementation. Thanks. |
Thanks for acknowledging that this is indeed an issue @eikenb! I am more than happy to make a PR after we make a decision of the right solution.
func toUnescapedJSON(t interface{}) (string, error) {
buf := &bytes.Buffer{}
encoder := json.NewEncoder(buf)
encoder.SetEscapeHTML(false)
err := encoder.Encode(t) // Encode leaves a \n character at the end of the sequence, we might want to trim the result.
if err != nil {
return "", errors.Wrap(err, "toUnescapedJSON")
}
return buffer.String(), err
} We could also create a encoder.SetIndent("", " ") What do you think? |
That sounds reasonable. Please include tests. Thanks. |
Hey @nagypeterjob, I took some time off for the holidays but will take a look at this as soon as I get a chance. Thanks! |
Missed that this didn't get auto-closed with the merge. Closing now. |
Consul Template version
v0.25.1
Configuration
Sample data
Expected behavior
The expected behavior is that the rendered secret (including
toJSONPretty
call) contains the value for keymongo_url
in the exact same format as provided via Vault.What should have happened?
The mongo connection string should not be HTML escaped.
Actual behavior
Actually the rendered secret messes up the value for
mongo_url
. Right now, the value formongo_url
key will look like this:What actually happened?
toJSON
andtoJSONPretty
generates json by calling the Golang standard library functionjson.Marshal
. It is well known thatjson.Marshal
HTML escapes the produced json string. Though It is still valid json, I wonder if in the context of Vault it is considered to be a "valid" and "desirable" side effect.As a resolution we could:
SetEscapeHTML
as in linkDo you think it is a valid problem?
The text was updated successfully, but these errors were encountered: