-
Notifications
You must be signed in to change notification settings - Fork 161
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
knife vault : Problem escaping string in JSON #346
Comments
Hi @tas50 I have worked on some part of this issue, My analysis is as below
@tas50 , Please share your thoughts so that we can proceed? |
@sanga1794 you need to escape the backslash (more than you might think), because backslash is a special escape character. in this example, it looks like there is a backslash in the password but that is actually
To understand that visually, look at
The string "looks like" it has three backslashes in it, but those are escape characters, combined with In this example:
That should probably be this, to get one backslash:
You can also see this work out by creating a hash in ruby with a properly escaped backslash (only has to be
If the JSON file is being created by hand, the user has to be aware of the requirement that any
https://github.com/chef/chef/blob/master/chef-config/lib/chef-config/path_helper.rb Maybe you could do the same thing in ChefVault::Mixin::Helper.values_from_json and have |
Here's further example:
|
Description
knife vault update some-vault serverabc -J data.json
where data.json contains:
When viewing this as json, the single backslash in the "agent_service_password" object does not appear
Chef Version
chef --version
Chef Workstation version: 0.11.21
Chef Infra Client version: 15.4.45
Chef InSpec version: 4.18.0
Chef CLI version: 2.0.0
Test Kitchen version: 2.3.4
Cookstyle version: 5.10.13
Related Issue
https://getchef.zendesk.com/agent/tickets/24443
Replication Case
Create a json with example data:
Run knife vault show some-vault serverabc -F json and the \ will not appear
Expected Behaviour
Backslash should be able to appear in string if escaped properly.
The text was updated successfully, but these errors were encountered: