From 2c138deb4fa9c1d9e1e7b1daa506d85eb3aa1666 Mon Sep 17 00:00:00 2001 From: Helen Campbell Date: Wed, 15 Mar 2017 11:13:45 +0000 Subject: (FM-6051) Adds comments to warn for UTF8 incompatibility --- lib/puppet/parser/functions/pw_hash.rb | 3 +++ 1 file changed, 3 insertions(+) (limited to 'lib/puppet/parser/functions/pw_hash.rb') diff --git a/lib/puppet/parser/functions/pw_hash.rb b/lib/puppet/parser/functions/pw_hash.rb index 41d4223..d99ee5b 100644 --- a/lib/puppet/parser/functions/pw_hash.rb +++ b/lib/puppet/parser/functions/pw_hash.rb @@ -1,3 +1,6 @@ + +# Please note: This function is an implementation of a Ruby class and as such may not be entirely UTF8 compatible. To ensure compatibility please use this function with Ruby 2.4.0 or greater - https://bugs.ruby-lang.org/issues/10085. + Puppet::Parser::Functions::newfunction( :pw_hash, :type => :rvalue, -- cgit v1.2.3 From 42d4ea7af9197f77a3062727eb166c719ca6296a Mon Sep 17 00:00:00 2001 From: Eric Putnam Date: Fri, 7 Jul 2017 17:30:17 -0700 Subject: (MODULES-4908) adds support for sensitive data type to pw_hash Also includes a small fix to integer_spec so tests pass. --- lib/puppet/parser/functions/pw_hash.rb | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'lib/puppet/parser/functions/pw_hash.rb') diff --git a/lib/puppet/parser/functions/pw_hash.rb b/lib/puppet/parser/functions/pw_hash.rb index d99ee5b..0deeb3a 100644 --- a/lib/puppet/parser/functions/pw_hash.rb +++ b/lib/puppet/parser/functions/pw_hash.rb @@ -27,6 +27,13 @@ Puppet::Parser::Functions::newfunction( environment contains several different operating systems, ensure that they are compatible before using this function.") do |args| raise ArgumentError, "pw_hash(): wrong number of arguments (#{args.size} for 3)" if args.size != 3 + args.map! do |arg| + if arg.is_a? Puppet::Pops::Types::PSensitiveType::Sensitive + arg.unwrap + else + arg + end + end raise ArgumentError, "pw_hash(): first argument must be a string" unless args[0].is_a? String or args[0].nil? raise ArgumentError, "pw_hash(): second argument must be a string" unless args[1].is_a? String hashes = { 'md5' => '1', -- cgit v1.2.3 From b1071e486578c63a4d93911585e02be44e9efbed Mon Sep 17 00:00:00 2001 From: Eric Putnam Date: Mon, 28 Aug 2017 09:34:27 -0700 Subject: (MODULES-5546) add check for pw_hash Older versions of Puppet end up choking on the sensitive data type check in the pw_hash function added in 42d4ea7af9197f77a3062727eb166c719ca6296a. this adds a check for the Sensitive class and then the type of the arg, so that if the class has not been declared, it will just move on. --- lib/puppet/parser/functions/pw_hash.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/puppet/parser/functions/pw_hash.rb') diff --git a/lib/puppet/parser/functions/pw_hash.rb b/lib/puppet/parser/functions/pw_hash.rb index 0deeb3a..adcc719 100644 --- a/lib/puppet/parser/functions/pw_hash.rb +++ b/lib/puppet/parser/functions/pw_hash.rb @@ -28,7 +28,7 @@ Puppet::Parser::Functions::newfunction( are compatible before using this function.") do |args| raise ArgumentError, "pw_hash(): wrong number of arguments (#{args.size} for 3)" if args.size != 3 args.map! do |arg| - if arg.is_a? Puppet::Pops::Types::PSensitiveType::Sensitive + if (defined? Puppet::Pops::Types::PSensitiveType::Sensitive) && (arg.is_a? Puppet::Pops::Types::PSensitiveType::Sensitive) arg.unwrap else arg -- cgit v1.2.3