mirror of
https://github.com/inspec/inspec
synced 2024-12-19 17:43:44 +00:00
c7e87ca3e3
* Create file-check functionality into utility file There are the similar issues as PR #2302. Almost resources return false positives when a file does not exist or is not read. * Replace to file-check functionality * Fix dh_params and x509_certificate resources If a file is empty, OpenSSL::PKey::DH and OpenSSL::X509::Certificate have raised an exception and have skipped the inspection. Thus x509_certificate and dh_params resources are not allowed to read a empty file. * to_s of shadow expects filters is not nil * Remove workaround of sshd_config Removes the workaround of sshd_config since Travis CI fails due to a bug of dev-sec/ssh-baseline and the PR #100 will fix it. * Use init block variable in methods Signed-off-by: ERAMOTO Masaya <eramoto.masaya@jp.fujitsu.com>
49 lines
1.5 KiB
Ruby
49 lines
1.5 KiB
Ruby
# encoding: utf-8
|
|
# author: Christoph Hartmann
|
|
# author: Dominik Richter
|
|
|
|
require 'helper'
|
|
require 'inspec/resource'
|
|
|
|
describe 'Inspec::Resources::SshConf' do
|
|
|
|
describe 'ssh_config' do
|
|
it 'check ssh config parsing' do
|
|
resource = load_resource('ssh_config')
|
|
_(resource.Host).must_equal '*'
|
|
_(resource.Tunnel).must_be_nil
|
|
_(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
|
|
it 'check protocol version' do
|
|
resource = load_resource('sshd_config')
|
|
_(resource.Port).must_equal '22'
|
|
_(resource.UsePAM).must_equal 'yes'
|
|
_(resource.ListenAddress).must_be_nil
|
|
_(resource.HostKey).must_equal [
|
|
'/etc/ssh/ssh_host_rsa_key',
|
|
'/etc/ssh/ssh_host_dsa_key',
|
|
'/etc/ssh/ssh_host_ecdsa_key',
|
|
]
|
|
end
|
|
|
|
it 'check bad path' do
|
|
resource = load_resource('sshd_config', '/etc/ssh/sshd_config_does_not_exist')
|
|
_(resource.resource_exception_message).must_equal "Can't find file: /etc/ssh/sshd_config_does_not_exist"
|
|
end
|
|
|
|
it 'check cannot read' do
|
|
resource = load_resource('sshd_config', '/etc/ssh/sshd_config_empty')
|
|
_(resource.resource_exception_message).must_equal "File is empty: /etc/ssh/sshd_config_empty"
|
|
end
|
|
end
|
|
end
|