Skip to content

Commit 5b21472

Browse files
committed
simplify tests
1 parent ba0d33e commit 5b21472

4 files changed

Lines changed: 1 addition & 65 deletions

File tree

default/serverspec/os_spec.rb

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -17,47 +17,29 @@
1717

1818
require 'spec_helper'
1919

20-
2120
describe command('find / -name \'.rhosts\' | wc -l ') do
2221
its(:stdout) { should match(/^0/) }
2322
end
2423

25-
2624
describe command('find / -name \'hosts.equiv\' | wc -l ') do
2725
its(:stdout) { should match(/^0/) }
2826
end
2927

30-
3128
describe file('/etc/shadow') do
3229
it { should be_owned_by 'root' }
33-
end
34-
35-
36-
describe file('/etc/shadow') do
3730
it { should be_mode 600 }
3831
end
3932

40-
4133
describe command('echo $PATH | grep -ci \'\.\'') do
4234
its(:stdout) { should match(/^0/) }
4335
end
4436

45-
4637
describe file('/etc/login.defs') do
4738
its(:content) { should match(%r{^ENV_SUPATH\s+PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin}) }
48-
end
49-
50-
51-
describe file('/etc/login.defs') do
5239
its(:content) { should match(%r{^ENV_PATH\s+PATH=/usr/local/bin:/usr/bin:/bin}) }
53-
end
54-
55-
56-
describe file('/etc/login.defs') do
5740
its(:content) { should match(/^UMASK +027/) }
5841
end
5942

60-
6143
describe 'SUID/ SGID blacklist check' do
6244
it 'found no blacklisted suid/sgid' do
6345
blacklist = [
@@ -93,7 +75,6 @@
9375
end
9476
end
9577

96-
9778
describe 'Unique uid' do
9879
it 'check for unique uids' do
9980
actual = command('cat /etc/passwd | cut -d \':\' -f 3').stdout.split(/\r?\n/)

default/serverspec/sysctl_spec.rb

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,27 +19,22 @@
1919

2020
describe 'IP V4 networking' do
2121

22-
2322
context linux_kernel_parameter('net.ipv4.ip_forward') do
2423
its(:value) { should eq 0 }
2524
end
2625

27-
2826
context linux_kernel_parameter('net.ipv4.conf.all.forwarding') do
2927
its(:value) { should eq 0 }
3028
end
3129

32-
3330
context linux_kernel_parameter('net.ipv4.conf.all.rp_filter') do
3431
its(:value) { should eq 1 }
3532
end
3633

37-
3834
context linux_kernel_parameter('net.ipv4.conf.default.rp_filter') do
3935
its(:value) { should eq 1 }
4036
end
4137

42-
4338
context linux_kernel_parameter('net.ipv4.icmp_echo_ignore_broadcasts') do
4439
its(:value) { should eq 1 }
4540
end
@@ -48,7 +43,6 @@
4843
its(:value) { should eq 1 }
4944
end
5045

51-
5246
context linux_kernel_parameter('net.ipv4.icmp_ratelimit') do
5347
its(:value) { should eq 100 }
5448
end
@@ -61,12 +55,10 @@
6155
its(:value) { should eq 0 }
6256
end
6357

64-
6558
context linux_kernel_parameter('net.ipv4.conf.all.arp_ignore') do
6659
its(:value) { should eq 1 }
6760
end
6861

69-
7062
context linux_kernel_parameter('net.ipv4.conf.all.arp_announce') do
7163
its(:value) { should eq 2 }
7264
end
@@ -87,12 +79,10 @@
8779
its(:value) { should eq 1 }
8880
end
8981

90-
9182
context linux_kernel_parameter('net.ipv4.conf.all.accept_source_route') do
9283
its(:value) { should eq 0 }
9384
end
9485

95-
9686
context linux_kernel_parameter('net.ipv4.conf.default.accept_source_route') do
9787
its(:value) { should eq 0 }
9888
end
@@ -134,7 +124,6 @@
134124
its(:value) { should eq 1 }
135125
end
136126

137-
138127
context linux_kernel_parameter('net.ipv6.conf.all.forwarding') do
139128
its(:value) { should eq 0 }
140129
end
@@ -206,7 +195,6 @@
206195

207196
describe 'ExecShield' do
208197

209-
210198
# check if we find the nx flag
211199
if command('cat /proc/cpuinfo').stdout =~ /^flags.*?:.*? nx( .*?)?$/
212200
true
@@ -221,7 +209,6 @@
221209
end
222210
end
223211

224-
225212
context linux_kernel_parameter('kernel.randomize_va_space') do
226213
its(:value) { should eq 2 }
227214
end

lockdown/serverspec/os_spec.rb

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -17,47 +17,29 @@
1717

1818
require 'spec_helper'
1919

20-
2120
describe command('find / -name \'.rhosts\' | wc -l ') do
2221
its(:stdout) { should match(/^0/) }
2322
end
2423

25-
2624
describe command('find / -name \'hosts.equiv\' | wc -l ') do
2725
its(:stdout) { should match(/^0/) }
2826
end
2927

30-
31-
describe file('/etc/shadow') do
32-
it { should be_owned_by 'root' }
33-
end
34-
35-
3628
describe file('/etc/shadow') do
3729
it { should be_mode 600 }
30+
it { should be_owned_by 'root' }
3831
end
3932

40-
4133
describe command('echo $PATH | grep -ci \'\.\'') do
4234
its(:stdout) { should match(/^0/) }
4335
end
4436

45-
4637
describe file('/etc/login.defs') do
4738
its(:content) { should match(%r{^ENV_SUPATH\s+PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin}) }
48-
end
49-
50-
51-
describe file('/etc/login.defs') do
5239
its(:content) { should match(%r{^ENV_PATH\s+PATH=/usr/local/bin:/usr/bin:/bin}) }
53-
end
54-
55-
56-
describe file('/etc/login.defs') do
5740
its(:content) { should match(/^UMASK +027/) }
5841
end
5942

60-
6143
describe 'SUID/ SGID whitelist check' do
6244
it 'found only whitelist suid/sgid' do
6345
whitelist = [
@@ -114,7 +96,6 @@
11496
end
11597
end
11698

117-
11899
describe 'Unique uid' do
119100
it 'check for unique uids' do
120101
actual = command('cat /etc/passwd | cut -d \':\' -f 3').stdout.split(/\r?\n/)

lockdown/serverspec/sysctl_spec.rb

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,27 +19,22 @@
1919

2020
describe 'IP V4 networking' do
2121

22-
2322
context linux_kernel_parameter('net.ipv4.ip_forward') do
2423
its(:value) { should eq 0 }
2524
end
2625

27-
2826
context linux_kernel_parameter('net.ipv4.conf.all.forwarding') do
2927
its(:value) { should eq 0 }
3028
end
3129

32-
3330
context linux_kernel_parameter('net.ipv4.conf.all.rp_filter') do
3431
its(:value) { should eq 1 }
3532
end
3633

37-
3834
context linux_kernel_parameter('net.ipv4.conf.default.rp_filter') do
3935
its(:value) { should eq 1 }
4036
end
4137

42-
4338
context linux_kernel_parameter('net.ipv4.icmp_echo_ignore_broadcasts') do
4439
its(:value) { should eq 1 }
4540
end
@@ -48,7 +43,6 @@
4843
its(:value) { should eq 1 }
4944
end
5045

51-
5246
context linux_kernel_parameter('net.ipv4.icmp_ratelimit') do
5347
its(:value) { should eq 100 }
5448
end
@@ -61,12 +55,10 @@
6155
its(:value) { should eq 0 }
6256
end
6357

64-
6558
context linux_kernel_parameter('net.ipv4.conf.all.arp_ignore') do
6659
its(:value) { should eq 1 }
6760
end
6861

69-
7062
context linux_kernel_parameter('net.ipv4.conf.all.arp_announce') do
7163
its(:value) { should eq 2 }
7264
end
@@ -87,12 +79,10 @@
8779
its(:value) { should eq 1 }
8880
end
8981

90-
9182
context linux_kernel_parameter('net.ipv4.conf.all.accept_source_route') do
9283
its(:value) { should eq 0 }
9384
end
9485

95-
9686
context linux_kernel_parameter('net.ipv4.conf.default.accept_source_route') do
9787
its(:value) { should eq 0 }
9888
end
@@ -134,7 +124,6 @@
134124
its(:value) { should eq 1 }
135125
end
136126

137-
138127
context linux_kernel_parameter('net.ipv6.conf.all.forwarding') do
139128
its(:value) { should eq 0 }
140129
end
@@ -198,7 +187,6 @@
198187

199188
describe 'ExecShield' do
200189

201-
202190
# check if we find the nx flag
203191
if command('cat /proc/cpuinfo').return_stdout?(/^flags.*?:.*? nx( .*?)?$/)
204192
true
@@ -213,7 +201,6 @@
213201
end
214202
end
215203

216-
217204
context linux_kernel_parameter('kernel.randomize_va_space') do
218205
its(:value) { should eq 2 }
219206
end

0 commit comments

Comments
 (0)