Faulty regex and usage of to_s triggers unwanted warning #379
Labels
Triage: Confirmed
Indicates and issue has been confirmed as described.
Type: Bug
Does not work as expected.
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 object
when a match is found, ornil
if no matches found) instead ofmatch?
(which actually returnstrue
if match is found andfalse
if not, as stated in the comments).Also, because of the usage of
to_s
inprintable?(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.The text was updated successfully, but these errors were encountered: