Skip to content

Commit 9fdcabb

Browse files
committed
rework CRYPTO_POLICY check to work with fedora
since fedora uses different version sheme it as not covered by previous check. Also add checks for ssh client, to see if we successfully override CRYPTO_POLICY there Signed-off-by: Martin Schurz <Martin.Schurz@t-systems.com>
1 parent 893eeb4 commit 9fdcabb

2 files changed

Lines changed: 18 additions & 2 deletions

File tree

controls/ssh_spec.rb

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,3 +227,19 @@
227227
its('UseRoaming') { should eq('no') }
228228
end
229229
end
230+
231+
control 'ssh-22' do
232+
impact 1.0
233+
title 'Client: CRYPTO_POLICY'
234+
desc 'Verifies, that we are not running CRYPTO_POLICY and our settings from ssh_config are effective'
235+
only_if('OS has CRYPTO_POLICY') do
236+
file('/etc/sysconfig/sshd').exist? && file('/etc/sysconfig/sshd').content.match?(/CRYPTO_POLICY/)
237+
end
238+
239+
describe bash("ssh -G localhost") do
240+
its('exit_status') { should eq 0 }
241+
its('stdout') { should match('ciphers ' + ssh_crypto.valid_ciphers) }
242+
its('stdout') { should match('kexalgorithms ' + ssh_crypto.valid_kexs) }
243+
its('stdout') { should match('macs ' + ssh_crypto.valid_macs) }
244+
end
245+
end

controls/sshd_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -508,8 +508,8 @@
508508
impact 1.0
509509
title 'Server: CRYPTO_POLICY'
510510
desc 'Verifies, that we are not running CRYPTO_POLICY and our settings from sshd_config are effective'
511-
only_if('OS is RHEL 8+ or compatible') do
512-
os[:family] == 'redhat' && ::Gem::Version.new(os.release) > ::Gem::Version.new('8')
511+
only_if('OS has CRYPTO_POLICY') do
512+
file('/etc/sysconfig/sshd').exist? && file('/etc/sysconfig/sshd').content.match?(/CRYPTO_POLICY/)
513513
end
514514

515515
describe bash("pgrep -af 'sshd -D'") do

0 commit comments

Comments
 (0)