Merge pull request #919 from chef/vj/case-insens-ssh-conf

ssh_config parse should be case insensitive
This commit is contained in:
Christoph Hartmann 2016-08-16 10:11:14 +02:00 committed by GitHub
commit cdfa8f720d
3 changed files with 17 additions and 2 deletions

View file

@ -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

View file

@ -3,3 +3,4 @@ Host *
# Tunnel no
SendEnv LANG LC_*
HashKnownHosts yes
GSSAPIAuthentication no

View file

@ -15,6 +15,12 @@ describe 'Inspec::Resources::SshConf' do
_(resource.SendEnv).must_equal 'LANG LC_*'
_(resource.HashKnownHosts).must_equal 'yes'
end
it 'is case insensitive' do
resource = load_resource('ssh_config')
_(resource.gssapiauthentication).must_equal 'no'
_(resource.GSSAPIAuthentication).must_equal 'no'
end
end
describe 'sshd_config' do