@@ -794,7 +794,7 @@ def prepare_credentials(resource)
794794 variable_name = random_variable_name
795795 credential_hash = {
796796 'user' => property_hash [ :value ] [ 'user' ] ,
797- 'password' => escape_quotes ( property_hash [ :value ] [ 'password' ] . unwrap )
797+ 'password' => escape_quotes ( unwrap_string ( property_hash [ :value ] [ 'password' ] ) )
798798 }
799799 credentials_block << format_pscredential ( variable_name , credential_hash )
800800 instantiated_variables . merge! ( variable_name => credential_hash )
@@ -899,7 +899,7 @@ def format_ciminstance(variable_name, class_name, property_hash)
899899 #
900900 # @param resource [Hash] a hash with the information needed to run `Invoke-DscResource`
901901 # @return [String] A string representing the PowerShell definition of the InvokeParams hash
902- def invoke_params ( resource )
902+ def invoke_params ( resource ) # rubocop:disable Metrics/MethodLength
903903 params = {
904904 Name : resource [ :dscmeta_resource_friendly_name ] ,
905905 Method : resource [ :dsc_invoke_method ] ,
@@ -917,6 +917,10 @@ def invoke_params(resource)
917917 params [ :ModuleName ] = resource [ :dscmeta_module_name ]
918918 end
919919 resource [ :parameters ] . each do |property_name , property_hash |
920+ # ignore dsc_timeout, since it is only used to specify the powershell command timeout
921+ # and timeout itself is not a parameter to the DSC resource
922+ next if property_name == :dsc_timeout
923+
920924 # strip dsc_ from the beginning of the property name declaration
921925 name = property_name . to_s . gsub ( /^dsc_/ , '' ) . to_sym
922926 params [ :Property ] [ name ] = case property_hash [ :mof_type ]
@@ -925,7 +929,7 @@ def invoke_params(resource)
925929 # the Credential hash interpolable as it will be replaced by a variable reference.
926930 {
927931 'user' => property_hash [ :value ] [ 'user' ] ,
928- 'password' => escape_quotes ( property_hash [ :value ] [ 'password' ] . unwrap )
932+ 'password' => escape_quotes ( unwrap_string ( property_hash [ :value ] [ 'password' ] ) )
929933 }
930934 when 'DateTime'
931935 # These have to be handled specifically because they rely on the *Puppet* DateTime,
@@ -1018,6 +1022,31 @@ def unwrap(value)
10181022 end
10191023 end
10201024
1025+ # Unwrap sensitive strings and handle string
1026+ #
1027+ # @param value [Object] The object to unwrap sensitive data inside of
1028+ # @return [Object] The object with any sensitive strings unwrapped
1029+ def unwrap_string ( value )
1030+ case value
1031+ when Puppet ::Pops ::Types ::PSensitiveType ::Sensitive
1032+ value . unwrap
1033+ when Hash
1034+ unwrapped = { }
1035+ value . each do |k , v |
1036+ unwrapped [ k ] = unwrap_string ( v )
1037+ end
1038+ unwrapped
1039+ when Array
1040+ unwrapped = [ ]
1041+ value . each do |v |
1042+ unwrapped << unwrap_string ( v )
1043+ end
1044+ unwrapped
1045+ else
1046+ value
1047+ end
1048+ end
1049+
10211050 # Escape any nested single quotes in a Sensitive string
10221051 #
10231052 # @param text [String] the text to escape
0 commit comments