Skip to content

Commit 907e58f

Browse files
Merge pull request #90 from Logicworks/main
CIS DIL Benchmark V2
2 parents 23134cd + cbb3183 commit 907e58f

26 files changed

+1930
-1038
lines changed

.rubocop.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ Documentation:
33
Enabled: false
44
Layout/ParameterAlignment:
55
Enabled: true
6+
Lint/AmbiguousRegexpLiteral:
7+
Enabled: false
68
HashSyntax:
79
Enabled: true
810
LineLength:
@@ -14,7 +16,7 @@ MethodLength:
1416
NumericLiterals:
1517
MinDigits: 10
1618
Metrics/BlockLength:
17-
Max: 40
19+
Max: 45 # needed for 6.1.1
1820
Metrics/CyclomaticComplexity:
1921
Max: 10
2022
Metrics/PerceivedComplexity:

controls/1_1_filesystem_configuration.rb

Lines changed: 65 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -123,12 +123,14 @@
123123
impact 1.0
124124

125125
tag cis: 'distribution-independent-linux:1.1.1.8'
126-
tag level: 1
126+
tag level: 2
127127

128128
describe kernel_module('vfat') do
129129
it { should_not be_loaded }
130130
it { should be_disabled }
131131
end
132+
133+
only_if { cis_level == 2 }
132134
end
133135

134136
control 'cis-dil-benchmark-1.1.2' do
@@ -153,7 +155,7 @@
153155
tag level: 1
154156

155157
describe mount('/tmp') do
156-
its(:options) { should include 'nodev' }
158+
its('options') { should include 'nodev' }
157159
end
158160
end
159161

@@ -166,7 +168,7 @@
166168
tag level: 1
167169

168170
describe mount('/tmp') do
169-
its(:options) { should include 'nosuid' }
171+
its('options') { should include 'nosuid' }
170172
end
171173
end
172174

@@ -179,7 +181,7 @@
179181
tag level: 1
180182

181183
describe mount('/tmp') do
182-
its(:options) { should include 'noexec' }
184+
its('options') { should include 'noexec' }
183185
end
184186
end
185187

@@ -219,9 +221,14 @@
219221
tag cis: 'distribution-independent-linux:1.1.8'
220222
tag level: 1
221223

224+
only_if('/var/tmp is mounted') do
225+
mount('/var/tmp').mounted?
226+
end
227+
222228
describe mount('/var/tmp') do
223-
its(:options) { should include 'nodev' }
229+
its('options') { should include 'nodev' }
224230
end
231+
225232
end
226233

227234
control 'cis-dil-benchmark-1.1.9' do
@@ -232,9 +239,14 @@
232239
tag cis: 'distribution-independent-linux:1.1.9'
233240
tag level: 1
234241

242+
only_if('/var/tmp is mounted') do
243+
mount('/var/tmp').mounted?
244+
end
245+
235246
describe mount('/var/tmp') do
236-
its(:options) { should include 'nosuid' }
247+
its('options') { should include 'nosuid' }
237248
end
249+
238250
end
239251

240252
control 'cis-dil-benchmark-1.1.10' do
@@ -245,9 +257,14 @@
245257
tag cis: 'distribution-independent-linux:1.1.10'
246258
tag level: 1
247259

260+
only_if('/var/tmp is mounted') do
261+
mount('/var/tmp').mounted?
262+
end
263+
248264
describe mount('/var/tmp') do
249-
its(:options) { should include 'noexec' }
265+
its('options') { should include 'noexec' }
250266
end
267+
251268
end
252269

253270
control 'cis-dil-benchmark-1.1.11' do
@@ -302,8 +319,12 @@
302319
tag cis: 'distribution-independent-linux:1.1.14'
303320
tag level: 1
304321

322+
only_if('/home is mounted') do
323+
mount('/home').mounted?
324+
end
325+
305326
describe mount('/home') do
306-
its(:options) { should include 'nodev' }
327+
its('options') { should include 'nodev' }
307328
end
308329
end
309330

@@ -315,8 +336,12 @@
315336
tag cis: 'distribution-independent-linux:1.1.15'
316337
tag level: 1
317338

339+
only_if('/dev/shm is mounted') do
340+
mount('/dev/shm').mounted?
341+
end
342+
318343
describe mount('/dev/shm') do
319-
its(:options) { should include 'nodev' }
344+
its('options') { should include 'nodev' }
320345
end
321346
end
322347

@@ -328,8 +353,12 @@
328353
tag cis: 'distribution-independent-linux:1.1.16'
329354
tag level: 1
330355

356+
only_if('/dev/shm is mounted') do
357+
mount('/dev/shm').mounted?
358+
end
359+
331360
describe mount('/dev/shm') do
332-
its(:options) { should include 'nosuid' }
361+
its('options') { should include 'nosuid' }
333362
end
334363
end
335364

@@ -342,7 +371,11 @@
342371
tag level: 1
343372

344373
describe mount('/dev/shm') do
345-
its(:options) { should include 'noexec' }
374+
its('options') { should include 'noexec' }
375+
end
376+
377+
only_if('/dev/shm is mounted') do
378+
mount('/dev/shm').mounted?
346379
end
347380
end
348381

@@ -394,7 +427,7 @@
394427
tag level: 1
395428

396429
describe command("df --local -P | awk '{ if (NR!=1) print $6 }' | xargs -I '{}' find '{}' -xdev -type d \( -perm -0002 -a ! -perm -1000 \)") do
397-
its(:stdout) { should eq '' }
430+
its('stdout') { should cmp '' }
398431
end
399432
end
400433

@@ -418,3 +451,23 @@
418451
end
419452
end
420453
end
454+
455+
control 'cis-dil-benchmark-1.1.23' do
456+
title 'Disable USB Storage'
457+
desc '
458+
USB storage provides a means to transfer and store files insuring persistence and availability of the files independent of network connection status.
459+
Its popularity and utility has led to USB-based malware being a simple and common means for network infiltration and a first step to establishing
460+
a persistent threat within a networked environment.
461+
'
462+
impact 1.0
463+
464+
tag cis: 'distribution-independent-linux:1.1.23'
465+
tag level: 1
466+
467+
# kernel modules need to use underscores
468+
# ref: https://github.com/inspec/inspec/issues/5190
469+
describe kernel_module('usb_storage') do
470+
it { should_not be_loaded }
471+
it { should be_disabled }
472+
end
473+
end

controls/1_3_filesystem_integrity_checking.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,14 @@
4848
describe.one do
4949
%w(/var/spool/cron/crontabs/root /var/spool/cron/root /etc/crontab).each do |f|
5050
describe file(f) do
51-
its(:content) { should match(/aide --check/) }
51+
its('content') { should match(/aide (--check|-C)/) }
5252
end
5353
end
5454

5555
%w(cron.d cron.hourly cron.daily cron.weekly cron.monthly).each do |f|
5656
command("find /etc/#{f} -type f").stdout.split.each do |entry|
5757
describe file(entry) do
58-
its(:content) { should match(/aide --check/) }
58+
its('content') { should match(/aide (--check|-C)/) }
5959
end
6060
end
6161
end

0 commit comments

Comments
 (0)