Skip to content

Commit 8d49cee

Browse files
authored
Merge pull request #6 from dev-sec/chris-rock/inspec-check
handle nil results for docker.path
2 parents dc85a1f + 542eb85 commit 8d49cee

1 file changed

Lines changed: 18 additions & 6 deletions

File tree

controls/docker_host_os_level1.rb

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -150,9 +150,15 @@
150150
desc 'Apart from auditing your regular Linux file system and system calls, audit all Docker related files and directories. Docker daemon runs with \'root\' privileges. Its behavior depends on some key files and directories. docker.service is one such file. The docker.service file might be present if the daemon parameters have been changed by an administrator. It holds various parameters for Docker daemon. It must be audited, if applicable.'
151151
ref 'https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/6/html/Security_Guide/chap-system_auditing.html'
152152

153-
rule = '-w ' << docker.path << ' -p rwxa -k docker'
154-
describe auditd_rules do
155-
its(:lines) { should include(rule) }
153+
unless docker.path.nil?
154+
rule = '-w ' << docker.path << ' -p rwxa -k docker'
155+
describe auditd_rules do
156+
its(:lines) { should include(rule) }
157+
end
158+
else
159+
describe 'audit docker service' do
160+
skip "Cannot determine docker path"
161+
end
156162
end
157163
end
158164

@@ -162,9 +168,15 @@
162168
desc 'Apart from auditing your regular Linux file system and system calls, audit all Docker related files and directories. Docker daemon runs with \'root\' privileges. Its behavior depends on some key files and directories. docker.service is one such file. The docker.service file might be present if the daemon parameters have been changed by an administrator. It holds various parameters for Docker daemon. It must be audited, if applicable.'
163169
ref 'https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/6/html/Security_Guide/chap-system_auditing.html'
164170

165-
rule = '-w ' << docker.socket << ' -p rwxa -k docker'
166-
describe auditd_rules do
167-
its(:lines) { should include(rule) }
171+
unless docker.path.nil?
172+
rule = '-w ' << docker.socket << ' -p rwxa -k docker'
173+
describe auditd_rules do
174+
its(:lines) { should include(rule) }
175+
end
176+
else
177+
describe 'audit docker service' do
178+
skip "Cannot determine docker socket"
179+
end
168180
end
169181
end
170182

0 commit comments

Comments
 (0)