Skip to content

Commit 728f680

Browse files
Merge pull request #112 from juju4/master
allow some customization of expected values depending on attributes
2 parents aa4eb82 + 686fba3 commit 728f680

File tree

1 file changed

+19
-9
lines changed

1 file changed

+19
-9
lines changed

controls/sshd_spec.rb

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,16 @@
1818

1919
title 'SSH server config'
2020

21+
sshd_valid_ciphers = attribute('sshd_valid_ciphers', default: ssh_crypto.valid_ciphers, description: 'Expected value for sshd_config ciphers')
22+
sshd_valid_kexs = attribute('sshd_valid_kexs', default: ssh_crypto.valid_kexs, description: 'Expected value for sshd_config kexs')
23+
sshd_valid_macs = attribute('sshd_valid_macs', default: ssh_crypto.valid_macs, description: 'Expected value for sshd_config macs')
24+
sshd_permittunnel = attribute('sshd_permittunnel', default: 'no', description: 'Expected value for sshd_config PermitTunnel')
25+
sshd_tcpforwarding = attribute('sshd_tcpforwarding', default: 'no', description: 'Expected value for sshd_config TcpForwarding')
26+
sshd_agentforwarding = attribute('sshd_agentforwarding', default: 'no', description: 'Expected value for sshd_config AgentForwarding')
27+
sshd_gatewayports = attribute('sshd_gatewayports', default: 'no', description: 'Expected value for sshd_config GatewayPorts')
28+
sshd_x11forwarding = attribute('sshd_x11forwarding', default: 'no', description: 'Expected value for sshd_config X11Forwarding')
29+
sshd_banner = attribute('sshd_banner', default: 'none', description: 'Expected value for sshd_config Banner')
30+
2131
only_if do
2232
command('sshd').exist?
2333
end
@@ -27,7 +37,7 @@
2737
title 'Server: Check for secure ssh ciphers'
2838
desc 'Configure a list of ciphers to the best secure ciphers (avoid older and weaker ciphers)'
2939
describe sshd_config do
30-
its('Ciphers') { should eq(ssh_crypto.valid_ciphers) }
40+
its('Ciphers') { should eq(sshd_valid_ciphers) }
3141
end
3242
end
3343

@@ -36,7 +46,7 @@
3646
title 'Server: Check for secure ssh Key-Exchange Algorithm'
3747
desc 'Configure a list of Key-Exchange Algorithms (Kexs) to the best secure Kexs (avoid older and weaker Key-Exchange Algorithm)'
3848
describe sshd_config do
39-
its('KexAlgorithms') { should eq(ssh_crypto.valid_kexs) }
49+
its('KexAlgorithms') { should eq(sshd_valid_kexs) }
4050
end
4151
end
4252

@@ -45,7 +55,7 @@
4555
title 'Server: Check for secure ssh Message Authentication Codes'
4656
desc 'Configure a list of Message Authentication Codes (MACs) to the best secure MACs (avoid older and weaker Message Authentication Codes)'
4757
describe sshd_config do
48-
its('MACs') { should eq(ssh_crypto.valid_macs) }
58+
its('MACs') { should eq(sshd_valid_macs) }
4959
end
5060
end
5161

@@ -372,7 +382,7 @@
372382
title 'Server: Disable tunnels'
373383
desc 'Avoid to use tunnels.'
374384
describe sshd_config do
375-
its('PermitTunnel') { should eq('no') }
385+
its('PermitTunnel') { should eq(sshd_permittunnel) }
376386
end
377387
end
378388

@@ -381,7 +391,7 @@
381391
title 'Server: Disable TCP forwarding'
382392
desc 'If you use TCP forwarding in an uncontrolled manner then you can bypass the firewalls'
383393
describe sshd_config do
384-
its('AllowTcpForwarding') { should eq('no') }
394+
its('AllowTcpForwarding') { should eq(sshd_tcpforwarding) }
385395
end
386396
end
387397

@@ -390,7 +400,7 @@
390400
title 'Server: Disable Agent forwarding'
391401
desc "Users with the ability to bypass file permissions on the remote host (for the agent's UNIX-domain socket) can access the local agent through the forwarded connection. An attacker cannot obtain key material from the agent, however they can perform operations on the keys that enable them to authenticate using the identities loaded into the agent."
392402
describe sshd_config do
393-
its('AllowAgentForwarding') { should eq('no') }
403+
its('AllowAgentForwarding') { should eq(sshd_agentforwarding) }
394404
end
395405
end
396406

@@ -399,7 +409,7 @@
399409
title 'Server: Disable gateway ports'
400410
desc 'Prevent remote hosts from connecting to forwarded ports on the node.'
401411
describe sshd_config do
402-
its('GatewayPorts') { should eq('no') }
412+
its('GatewayPorts') { should eq(sshd_gatewayports) }
403413
end
404414
end
405415

@@ -408,7 +418,7 @@
408418
title 'Server: Disable X11Forwarding'
409419
desc 'Prevent X11 forwarding by default, as it can be used in a limited way to enable attacks.'
410420
describe sshd_config do
411-
its('X11Forwarding') { should eq('no') }
421+
its('X11Forwarding') { should eq(sshd_x11forwarding) }
412422
end
413423
end
414424

@@ -444,7 +454,7 @@
444454
title 'Server: Banner'
445455
desc 'Specifies a banner file to serve before authentication succeeds'
446456
describe sshd_config do
447-
its('Banner') { should eq('none') }
457+
its('Banner') { should eq(sshd_banner) }
448458
end
449459
end
450460

0 commit comments

Comments
 (0)