Skip to content

Commit 0ddc66d

Browse files
Merge pull request #180 from schurzi/crypto_policy
check for CRYPTO_POLICY should also work, when not root
2 parents e5a7630 + d4b987f commit 0ddc66d

File tree

2 files changed

+10
-11
lines changed

2 files changed

+10
-11
lines changed

controls/ssh_spec.rb

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -231,13 +231,12 @@
231231
control 'ssh-22' do
232232
impact 1.0
233233
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/)
234+
desc 'Verifies, that we are not running CRYPTO_POLICY and our settings from ssh_config are effective (affects el8+ and fedora)'
235+
only_if('ssh client supports -G option') do
236+
bash('ssh -G localhost').exit_status.equal?(0)
237237
end
238238

239239
describe bash('ssh -G localhost') do
240-
its('exit_status') { should eq 0 }
241240
its('stdout') { should match('ciphers ' + ssh_crypto.valid_ciphers) }
242241
its('stdout') { should match('kexalgorithms ' + ssh_crypto.valid_kexs) }
243242
its('stdout') { should match('macs ' + ssh_crypto.valid_macs) }

controls/sshd_spec.rb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -508,14 +508,14 @@
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 has CRYPTO_POLICY') do
512-
file('/etc/sysconfig/sshd').exist? && file('/etc/sysconfig/sshd').content.match?(/CRYPTO_POLICY/)
511+
only_if('sshd with options is running') do
512+
processes('sshd -D').exists?
513513
end
514514

515-
describe bash("pgrep -af 'sshd -D'") do
516-
its('exit_status') { should eq 0 }
517-
its('stdout') { should_not match('-oCiphers') }
518-
its('stdout') { should_not match('-oKexAlgorithms') }
519-
its('stdout') { should_not match('-oHostKeyAlgorithms') }
515+
describe processes('sshd -D') do
516+
its('entries.length') { should eq 1 }
517+
its('commands.first') { should_not match(/-oCiphers/) }
518+
its('commands.first') { should_not match(/-oKexAlgorithms/) }
519+
its('commands.first') { should_not match(/-oHostKeyAlgorithms/) }
520520
end
521521
end

0 commit comments

Comments
 (0)