Skip to content

Commit 33ec3c3

Browse files
committed
Error handling and style
1 parent d8ff99b commit 33ec3c3

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

modules/exploits/linux/http/docker_daemon_tcp.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def check_image(image_id)
5454
'method' => 'GET',
5555
'uri' => normalize_uri('images', 'json')
5656
)
57-
return unless res and res.code == 200 and res.body.include? image_id
57+
return unless res && res.code == 200 && res.body.include?(image_id)
5858

5959
res
6060
end
@@ -65,7 +65,7 @@ def pull_image(image_id)
6565
'method' => 'POST',
6666
'uri' => normalize_uri('images', 'create?fromImage=' + image_id)
6767
)
68-
return unless res.code == 200
68+
return unless res && res.code == 200
6969

7070
res
7171
end
@@ -125,7 +125,7 @@ def check
125125
return Exploit::CheckCode::Unknown
126126
end
127127

128-
if res and res.code == 200 and res.headers['Server'].include? 'Docker'
128+
if res && res.code == 200 && res.headers['Server'].include?('Docker')
129129
return Exploit::CheckCode::Vulnerable
130130
end
131131

@@ -181,7 +181,7 @@ def exploit
181181

182182
# delete container
183183
deleted_container = false
184-
if res_wait.code == 200
184+
if res_wait && res_wait.code == 200
185185
vprint_status("The docker container has been stopped, now trying to remove it")
186186
del_container(container_id)
187187
deleted_container = true

0 commit comments

Comments
 (0)