mirror of
https://github.com/inspec/inspec
synced 2024-11-27 07:00:39 +00:00
ssh_config parse should be case insensitive
This commit is contained in:
parent
b86c1bd4c5
commit
cf771ab967
3 changed files with 17 additions and 2 deletions
|
@ -32,8 +32,16 @@ module Inspec::Resources
|
|||
end
|
||||
end
|
||||
|
||||
def convert_hash(hash)
|
||||
new_hash = {}
|
||||
hash.each do |k,v|
|
||||
new_hash[k.downcase] = v
|
||||
end
|
||||
new_hash
|
||||
end
|
||||
|
||||
def method_missing(name)
|
||||
param = read_params[name.to_s]
|
||||
param = read_params[name.to_s.downcase]
|
||||
return nil if param.nil?
|
||||
# extract first value if we have only one value in array
|
||||
return param[0] if param.length == 1
|
||||
|
@ -69,7 +77,7 @@ module Inspec::Resources
|
|||
assignment_re: /^\s*(\S+?)\s+(.*?)\s*$/,
|
||||
multiple_values: true,
|
||||
)
|
||||
@params = conf.params
|
||||
@params = convert_hash(conf.params)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -3,3 +3,4 @@ Host *
|
|||
# Tunnel no
|
||||
SendEnv LANG LC_*
|
||||
HashKnownHosts yes
|
||||
GSSAPIAuthentication no
|
||||
|
|
|
@ -14,6 +14,12 @@ describe 'Inspec::Resources::SshConf' do
|
|||
_(resource.Tunnel).must_equal nil
|
||||
_(resource.SendEnv).must_equal 'LANG LC_*'
|
||||
_(resource.HashKnownHosts).must_equal 'yes'
|
||||
puts resource
|
||||
end
|
||||
|
||||
it 'is case insensitive' do
|
||||
resource = load_resource('ssh_config')
|
||||
_(resource.gssapiauthentication).must_equal 'no'
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue