fix #1268 and allows registry key resource with leading backslash

Signed-off-by: Christoph Hartmann <chris@lollyrock.com>
This commit is contained in:
Christoph Hartmann 2017-04-06 23:30:10 +02:00
parent 7562138248
commit 90b985a7c1
2 changed files with 22 additions and 1 deletions

View file

@ -66,7 +66,10 @@ module Inspec::Resources
# generate registry_key if we do not have a regular expression
@options[:path] = @options[:hive]
# add optional key path
@options[:path] += '\\' + @options[:key] if @options[:key]
if @options[:key]
@options[:path] += '\\' if !@options[:key].start_with?('\\')
@options[:path] += @options[:key]
end
@options[:name] ||= @options[:path]
else
@options[:name] = name

View file

@ -111,3 +111,21 @@ control 'regex-test' do
end
}
end
# test key without leading slash
describe registry_key({
hive: 'HKLM',
key: 'System\Test',
}) do
it { should exist }
it { should have_value('test') }
end
# test key with leading slash
describe registry_key({
hive: 'HKLM',
key: '\System\Test',
}) do
it { should exist }
it { should have_value('test') }
end