mirror of
https://github.com/inspec/inspec
synced 2024-09-21 06:51:56 +00:00
fix #1131 circumvent bug in powershell where string are not properly handled
Signed-off-by: Christoph Hartmann <chris@lollyrock.com>
This commit is contained in:
parent
90b985a7c1
commit
6f6f3985a6
4 changed files with 21 additions and 3 deletions
|
@ -168,7 +168,7 @@ module Inspec::Resources
|
|||
$properties
|
||||
}
|
||||
$path = '#{path}'
|
||||
InSpec-GetRegistryKey($path) | ConvertTo-Json
|
||||
InSpec-GetRegistryKey($path) | ConvertTo-Json -Compress
|
||||
EOH
|
||||
|
||||
cmd = inspec.powershell(script)
|
||||
|
|
|
@ -31,6 +31,14 @@ if node['platform_family'] == 'windows'
|
|||
:name => 'multistring value',
|
||||
:type => :multi_string,
|
||||
:data => ['test', 'multi','string','data']
|
||||
},{
|
||||
:name => 'super\/escape',
|
||||
:type => :string,
|
||||
:data => '\/value/\\'
|
||||
},{
|
||||
:name => 'key.with.dot',
|
||||
:type => :string,
|
||||
:data => 'value.with.dot'
|
||||
}]
|
||||
recursive true
|
||||
action :create
|
||||
|
|
|
@ -163,8 +163,7 @@ class MockLoader
|
|||
'env' => cmd.call('env'),
|
||||
'${Env:PATH}' => cmd.call('$env-PATH'),
|
||||
# registry key test using winrm 2.0
|
||||
'2376c7b3d81de9382303356e1efdea99385effb84788562c3e697032d51bf942' => cmd.call('reg_schedule'),
|
||||
'89b48f91634e7efc40105fc082c5e12693b08c0a7c4a578b1f3a07e34f676c66' => cmd.call('reg_schedule'),
|
||||
'bd15a11a4b07de0224c4d1ab16c49ad78dd6147650c6ef629152c7093a5ac95e' => cmd.call('reg_schedule'),
|
||||
'Auditpol /get /subcategory:\'User Account Management\' /r' => cmd.call('auditpol'),
|
||||
'/sbin/auditctl -l' => cmd.call('auditctl'),
|
||||
'/sbin/auditctl -s' => cmd.call('auditctl-s'),
|
||||
|
|
|
@ -129,3 +129,14 @@ describe registry_key({
|
|||
it { should exist }
|
||||
it { should have_value('test') }
|
||||
end
|
||||
|
||||
describe registry_key('HKLM\System\Test') do
|
||||
it { should exist }
|
||||
its('super\/escape') { should eq '\/value/\\' }
|
||||
|
||||
# its('key.with.dot') { should eq 'value.with.dot' }
|
||||
# does not work due to the . inside the its block
|
||||
# see https://github.com/chef/inspec/issues/1281
|
||||
# use the following solution:
|
||||
it { should have_property_value('key.with.dot', :string, 'value.with.dot') }
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue