Version:
chef-vault-4.1.3
Environment:
Alpine Linux
Scenario:
As the new version of the chef-vault gem was released (4.1.3), when doing
knife vault create env secrets -M client -J creds.json -A admin1 -C "client1,client2"
it shows a warning
WARN: Value '[{:api_version=>"api/v3", :metadata=>{}, :data=>{:enabled=>true, :groups=>["test"], :password=>"testpass", :username=>"test"}, :type=>"User"}]' of key 'users' contains non-printable characters. Check that backslashes are escaped with another backslash (e.g. C:\\Windows) in double-quoted strings.
Expected Result:
Not printing any warning.
Not printing the value of the key in the warning.
An accurate suggestion in the warning because in my case i don't have any backslashes but actually whitespaces.
Additional Context:
In lib/chef/knife/mixin/helper.rb, the printable? function uses match (which returns a MatchData object when a match is found, or nil if no matches found) instead of match? (which actually returns true if match is found and false if not, as stated in the comments).
Also, because of the usage of to_s in printable?(value.to_s), the value is pretty-printed and matches the [[:space:]] if you have values like "a b c" or like mine (in the scenario above). Leaving the regex just with [^[:print:]] like it was before would solve the problem and not trigger any warning.
Version:
chef-vault-4.1.3
Environment:
Alpine Linux
Scenario:
As the new version of the chef-vault gem was released (4.1.3), when doing
knife vault create env secrets -M client -J creds.json -A admin1 -C "client1,client2"it shows a warning
WARN: Value '[{:api_version=>"api/v3", :metadata=>{}, :data=>{:enabled=>true, :groups=>["test"], :password=>"testpass", :username=>"test"}, :type=>"User"}]' of key 'users' contains non-printable characters. Check that backslashes are escaped with another backslash (e.g. C:\\Windows) in double-quoted strings.Expected Result:
Not printing any warning.
Not printing the value of the key in the warning.
An accurate suggestion in the warning because in my case i don't have any backslashes but actually whitespaces.
Additional Context:
In
lib/chef/knife/mixin/helper.rb, theprintable?function usesmatch(which returns aMatchData objectwhen a match is found, ornilif no matches found) instead ofmatch?(which actually returnstrueif match is found andfalseif not, as stated in the comments).Also, because of the usage of
to_sinprintable?(value.to_s), the value is pretty-printed and matches the[[:space:]]if you have values like "a b c" or like mine (in the scenario above). Leaving the regex just with[^[:print:]]like it was before would solve the problem and not trigger any warning.