-
Notifications
You must be signed in to change notification settings - Fork 160
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
Replaced exception with the warnings and removed related failing specs(used earlier for raising issue) #367
Replaced exception with the warnings and removed related failing specs(used earlier for raising issue) #367
Conversation
@@ -59,7 +59,7 @@ def validate_json(json) | |||
next unless printable?(value.to_s) |
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.
shouldn't printable just be changed to also match whitespace?
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.
Hi @lamont-granquist , for the whitespace it is working fine without any issue as shwon below
json file content:
{
"id": "test1",
"text1": "my passwords",
"username": "root"
}
bundle exec knife vault update test test1 -J ../../chef-repo/root.json -c ../../chef-repo/.chef/knife.rb
bundle exec knife vault show test test1 -c ../../chef-repo/.chef/knife.rb
id: test1
text1: my passwords
username: root
Based on this is there a need to add warnings for whitespace? It should be be fine here to not add warning IMO. Please suggest.
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'm talking about adding [[:space:]]
to the match for printable?
which also matches \n
and \r
and \t
in addition to ascii space and various unicode spaces.
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.
you probably want to just use String#valid_encoding?
though. or use the String#encode!
method to convert the string to UTF-8 but raise on any errors rather than replacing.
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'm talking about adding
[[:space:]]
to the match forprintable?
which also matches\n
and\r
and\t
in addition to ascii space and various unicode spaces.
Okk, will add [[:space:]]
Thanks @lamont-granquist !
Hi @lamont-granquist, I have added the regex for whitesapce, Please have look into it. Thanks!! |
Can we get an update on this case for the customer. Thank you |
@lamont-granquist Please have look into the latest changes, Thanks!! |
@sanga1794 Hi. I often use chef-vault and am having trouble with this problem. This problem(pull requiest) seems to have stopped for a long time, is there any problem? I hope for a quick solution. :-) |
@@ -59,7 +59,7 @@ def validate_json(json) | |||
next unless printable?(value.to_s) | |||
|
|||
msg = "Value '#{value}' of key '#{key}' contains non-printable characters. Check that backslashes are escaped with another backslash (e.g. C:\\\\Windows) in double-quoted strings." | |||
raise ChefVault::Exceptions::InvalidValue, msg | |||
ChefVault::Log.warn(msg) |
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 believe an Exception still needs to be raised as before, except that the allowed characters have expanded.
@@ -5,18 +5,13 @@ | |||
include ChefVault::Mixin::Helper | |||
|
|||
let(:json_data) { '{"username": "root", "password": "abcabc"}' } | |||
let(:json_data_control_char) { '{"username": "root", "password": "abc\abc"}' } | |||
let(:buggy_json_data) { '{"username": "root", "password": "abc\abc"' } |
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 be good to add tests that ensure we allow for tabspace, whitespace and newline going forward.
366518f
to
f051821
Compare
Signed-off-by: sanga17 <[email protected]>
Signed-off-by: sanga17 <[email protected]>
Signed-off-by: sanga17 <[email protected]>
f051821
to
412b297
Compare
Signed-off-by: sanga17 [email protected]
Description
When uploading vault item that contains \n errors with the below message.
Check that backslashes are escaped with another backslash (e.g. C:\Windows) in double-quoted strings.
Looking at that error, we changed the \n to \n and the error stops BUT the content vault item actually have \n and no new line is inserted.
Before Fix:
After Fix:
Related Issue
Fixed: https://github.com/chef/chef-vault/issues/366
Types of changes
Checklist: