Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Strange registry_key behavior (Unable to get .NET Version) #1131

Closed
jerryaldrichiii opened this issue Sep 22, 2016 · 10 comments
Closed

Strange registry_key behavior (Unable to get .NET Version) #1131

jerryaldrichiii opened this issue Sep 22, 2016 · 10 comments
Assignees

Comments

@jerryaldrichiii
Copy link
Contributor

jerryaldrichiii commented Sep 22, 2016

Description

Intended Goal

I am attempting to get the following test to pass:

describe registry_key('HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/NET Framework Setup/NDP/v4/Full') do
  its('Release') { should eq 378_765 }
end

Problem

I can only get the value of nil for Release

More Info

Using / or placing an extra \ somewhere in the path allows the tests below to pass...however it does not allow me to get the value of Release.

describe registry_key('HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full') do
  it { should exist } # Fails
  its('Release') { should eq 378_765 } # Fails
end

describe registry_key('HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Fu\ll') do
  it { should exist } # Passes (See `Full` above)
  its('Release') { should eq 378_765 } # Fails
end

describe registry_key('HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/NET Framework Setup/NDP/v4/Full') do
  it { should exist } # Passes
  its('Release') { should eq 378_765 } # Fails
end

Also, it appears cannot get the value of any key under v4 but can under v4.0. See:

describe registry_key('HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Client') do
  its('Install') { should eq 1 } #Fails
end

describe registry_key('HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4.0\Client') do
  its('Install') { should eq 1 } #Passes
end

Picture of Registry

screen shot 2016-09-22 at 3 13 53 pm

### InSpec and Platform Version

InSpec Version: 0.29.0
Platform: Windows 2012R2

@chris-rock
Copy link
Contributor

@jeremiahsnapp can you upgrade to at least inspec 0.30.0? we’ve updated the registry key resource by then

@chris-rock
Copy link
Contributor

Is this executed remotely or locally?

@jerryaldrichiii
Copy link
Contributor Author

jerryaldrichiii commented Sep 22, 2016

It is executed remotely via Test Kitchen. Here are the versions from ChefDK:

Chef Development Kit Version: 0.17.17
chef-client version: 12.13.37
delivery version: master (f68e5c5804cd7d8a76c69b926fbb261e1070751b)
berks version: 4.3.5
kitchen version: 1.11.1

@jerryaldrichiii
Copy link
Contributor Author

jerryaldrichiii commented Sep 22, 2016

After updating to version 0.30.0 of InSpec via chef exec gem install inspec -v 0.30.0, the issue is still present.

@brianbohanon
Copy link

brianbohanon commented Sep 23, 2016

I am experiencing similar behavior on 64-bit Windows. It seems inspec is not able to access certain keys under HKLM\SOFTWARE in 64-bit Windows. My testing has shown that inspec can detect if any non-Microsoft key { should exist } in HKLM\SOFTWARE, but not any properties or values within those keys. It seems that it is able to access HKLM\SOFTWARE\Microsoft keys, properties, and values. I haven't found anything definitive, but so far things seem to be pointing towards Microsoft's redirected registry.

Example 1: Works on 2008x86 (WMF 3.0), 2008r2 (WMF 3.0)

describe registry_key('HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Client') do
  its('Install') { should eq 1 }
end

Example 2: Works on 2008x86 (WMF 3.0), 2008r2 (WMF 3.0)

describe registry_key('HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4.0\Client') do
  its('Install') { should eq 1 }
end

Example 3: Works on 2008x86 (WMF 3.0), 2008r2 (WMF 3.0)

describe registry_key('HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\v2.0.50727') do
  its('AspNetEnforceViewStateMac') { should eq 1 }
end

Example 4: Works on 2008x86 (WMF 3.0), NOT on 2008r2 (WMF 3.0)

describe registry_key('HKEY_LOCAL_MACHINE\SOFTWARE\Oracle\VirtualBox Guest Additions') do
  its('Version') { should eq '5.0.26' }
end

Example 5: Works on 2008x86 (WMF 3.0), NOT on 2008r2 (WMF 3.0)

describe registry_key('HKEY_LOCAL_MACHINE\SOFTWARE\ATI Technologies\Install\South Bridge\ATI_AHCI_RAID') do
  its('Install') { should eq 'Success' }
end
  • Inspec version 0.34.0
  • Testing locally
  • All registry keys exist on both servers and can be viewed in Registry Editor

@kenmacleod
Copy link

I had the same issue on 2012r2 and upgrading to WMF 5.0 fixed the issue. See also #939.

@JackChance
Copy link
Contributor

Seeing this same issue.

describe.one do
  describe file('C:\\NDP462-KB3151800-x86-x64-AllOS-ENU.exe') do
    it { should exist }
  end

  describe registry_key('HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full') do
    its('Release') { should eq 394_806 }
  end
end

chef -v:
Chef Development Kit Version: 1.1.16
chef-client version: 12.17.44
delivery version: master (83358fb62c0f711c70ad5a81030a6cae4017f103)
berks version: 5.2.0
kitchen version: 1.14.2

chef gem list inspec:
debug_inspector (0.0.2)
inspec (1.7.2)
kitchen-inspec (0.17.0)

Guest server OS is 2012r2 with powershell 4

@chris-rock
Copy link
Contributor

@JackChance Can you do me a favor and update to the latest ChefDK to ensure we have that issue in the latest versions? ChefDK is available here: https://downloads.chef.io/chefdk/1.2.22

@JackChance
Copy link
Contributor

@chris-rock upgraded my chefdk and I'm still seeing the same behavior.

  File C:\NDP462-KB3151800-x86-x64-AllOS-ENU.exe
     ∅  expected File C:\NDP462-KB3151800-x86-x64-AllOS-ENU.exe to exist

     expected File C:\NDP462-KB3151800-x86-x64-AllOS-ENU.exe to exist
     ∅
     expected: 394806
          got: nil

     (compared using ==)



     expected: 394806
          got: nil

     (compared using ==)


Test Summary: 22 successful, 2 failures, 0 skipped
>>>>>> ------Exception-------
>>>>>> Class: Kitchen::ActionFailed
>>>>>> Message: 1 actions failed.
>>>>>>     Verify failed on instance <web-services-win2012r2>.  Please see .kitchen/logs/web-services-win2012r2.log for more details
>>>>>> ----------------------
>>>>>> Please see .kitchen/logs/kitchen.log for more details
>>>>>> Also try running `kitchen diagnose --all` for configuration

strakaca@BOT0019D MINGW64 ~/git/cookbooks/vertafore_aa3 (master)
$ chef -v
Chef Development Kit Version: 1.2.22
chef-client version: 12.18.31
delivery version: master (0b746cafed65a9ea1a79de3cc546e7922de9187c)
berks version: 2017-03-14T13:51:03.830129 41532] 2017-03-14T13:51:03.830614 41532] 2017-03-14T13:51:03.830614 41532] 2017-03-14T13:51:03.830614 41532] 2017-03-14T13:51:03.898713 41532] 2017-03-14T13:51:03.898713 41532] 5.6.0
kitchen version: 1.15.0

Host machine is windows 10 btw.
Also would have expected only 1 failure report as those both exist in a describe.one block, not that it matters much.

@Belogix
Copy link

Belogix commented Mar 24, 2017

I am having the same issue as you. My work-around for now is to use the child folder 1033. Why it can access the child folder but not the main folder I have no idea!

Please try and see if this works for you too.

describe registry_key('HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full\1033') do
  it { should exist }
  its('Release') { should cmp '394271' }
end

chris-rock added a commit that referenced this issue Apr 6, 2017
…handled

Signed-off-by: Christoph Hartmann <chris@lollyrock.com>
@chris-rock chris-rock self-assigned this Apr 6, 2017
chris-rock added a commit that referenced this issue Apr 7, 2017
…handled

Signed-off-by: Christoph Hartmann <chris@lollyrock.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants