As part of making Puppet 4 compatible with Ruby 2.1.5, we have discovered a couple of bugs inside Ruby that will affect your module. The two primary issues are:
When enumerating keys with #each_key / #keys or values with #each_value / #values, Ruby will take a UTF-16LE string and roundtrip it through the local codepage unnecessarily, which may cause encoding exceptions. Our prime example of this is when a Unicode en-dash U+2013 appears in a registry value, and the local codepage is IBM437, which has no equivalent character. This is just one of many potential examples that may trigger this behavior. NOTE: Normal registry reads of a value at a particular key are not problematic - the bad behavior is only triggered during enumeration. We have not yet filed this bug with Ruby.
I have identified issues with the code in this module that will require some updating to ensure it maintains compatibility with both existing Puppet releases and the upcoming releases. I'm getting in touch with you now, so that you're not caught off guard, and so that your module is ready to go by the time 4.0 ships.
You might want to also verify the module by hand using a Ruby 2.1.5 runtime. To do this requires modifying registry.rb, present at c:\tools\ruby215\lib\ruby\2.1.0\win32\registry.rb in my install. Some simple warnings may be emitted in several locations where problematic behavior can occur. Then you can exercise your module / run specs for a full validation.
Optionally https://github.com/ruby/ruby/blob/v2_1_5/ext/win32/lib/win32/registry.rb#L363 can have puts "BUG: expand_environ triggered with #{str}" - while this behavior does trigger a string re-encode to the current codepage, we view it as less problematic as it requires REG_MULTI_SZ and environment variable expansion - where the values will typically be in the current codepage on a default system.
As part of making Puppet 4 compatible with Ruby 2.1.5, we have discovered a couple of bugs inside Ruby that will affect your module. The two primary issues are:
#each_key
/#keys
or values with#each_value
/#values
, Ruby will take aUTF-16LE
string and roundtrip it through the local codepage unnecessarily, which may cause encoding exceptions. Our prime example of this is when a Unicode en-dashU+2013
appears in a registry value, and the local codepage isIBM437
, which has no equivalent character. This is just one of many potential examples that may trigger this behavior. NOTE: Normal registry reads of a value at a particular key are not problematic - the bad behavior is only triggered during enumeration. We have not yet filed this bug with Ruby.#delete_key
and#delete_value
methods, Ruby is passing wide characterUTF-16LE
strings to ANSI APIs. We have filed this bug with Ruby at https://bugs.ruby-lang.org/issues/10820There are additional technical details that can be found in PUP-3837, the ticket we're using to track changes that we've made to Puppet. Our resolution for these issues was merged to Puppet at https://github.com/puppetlabs/puppet/commit/c610cd01eeef3fafa7aa2761a3435dd6c1b0d8d4
We don't have Puppet 4 builds released yet, but keep an eye on https://groups.google.com/forum/#!forum/puppet-announce
I have identified issues with the code in this module that will require some updating to ensure it maintains compatibility with both existing Puppet releases and the upcoming releases. I'm getting in touch with you now, so that you're not caught off guard, and so that your module is ready to go by the time 4.0 ships.
Issues:
each
is called at https://github.com/liamjbennett/puppet-win_facts/blob/master/lib/facter/operatingsystemversion.rb#L18, https://github.com/liamjbennett/puppet-win_facts/blob/master/lib/facter/windows_productkey.rb#L55 and https://github.com/liamjbennett/puppet-win_facts/blob/master/lib/facter/windows_sid.rb#L22, which will trigger the errant Ruby behavior. Instead, use an internal FFI definition for theRegEnumKeyW
andRegEnumValueW
API calls like we've done inside Puppet at https://github.com/puppetlabs/puppet/blob/c610cd01eeef3fafa7aa2761a3435dd6c1b0d8d4/lib/puppet/util/windows/registry.rb#L89-L149registry.rb
, present atc:\tools\ruby215\lib\ruby\2.1.0\win32\registry.rb
in my install. Some simple warnings may be emitted in several locations where problematic behavior can occur. Then you can exercise your module / run specs for a full validation.puts "BUG: RegDeleteValue called with #{name} against #{@keyname}"
puts "BUG: RegDeleteKey called with #{name} against #{@keyname}"
addedputs "BUG: export_string triggered with #{str} to #{enc.to_s}"
puts "BUG: expand_environ triggered with #{str}"
- while this behavior does trigger a string re-encode to the current codepage, we view it as less problematic as it requiresREG_MULTI_SZ
and environment variable expansion - where the values will typically be in the current codepage on a default system.We will be making an announcement to the puppet-dev list shortly mentioning some of these upcoming changes. https://groups.google.com/forum/#!forum/puppet-dev
Let me know if you have any questions.
Thanks!