mirror of
https://github.com/inspec/inspec
synced 2024-11-10 23:24:18 +00:00
fix #1268 and allows registry key resource with leading backslash
Signed-off-by: Christoph Hartmann <chris@lollyrock.com>
This commit is contained in:
parent
7562138248
commit
90b985a7c1
2 changed files with 22 additions and 1 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue