Skip to content

Commit 244c901

Browse files
committed
rancher review
1 parent 0cd174c commit 244c901

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

modules/auxiliary/gather/rancher_authenticated_api_cred_exposure.rb

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ def initialize(info = {})
4646
)
4747
register_options(
4848
[
49-
OptString.new('USERNAME', [ true, 'User to login with', '']),
50-
OptString.new('PASSWORD', [ true, 'Password to login with', '']),
49+
OptString.new('USERNAME', [ true, 'User to login with']),
50+
OptString.new('PASSWORD', [ true, 'Password to login with']),
5151
OptString.new('TARGETURI', [ true, 'The URI of Rancher instance', '/'])
5252
]
5353
)
@@ -66,14 +66,11 @@ def rancher?
6666
'uri' => normalize_uri(target_uri.path, 'dashboard/'),
6767
'keep_cookies' => true
6868
})
69-
return false if res.nil?
70-
return false unless res.code == 200
69+
return false unless res&.code == 200
7170

7271
html = res.get_html_document
7372
title = html.at('title').text
74-
return true if title == 'dashboard' # this is a VERY weak check
75-
76-
false
73+
title == 'dashboard' # this is a VERY weak check
7774
end
7875

7976
def login
@@ -83,7 +80,7 @@ def login
8380
'keep_cookies' => true
8481
})
8582
fail_with(Failure::Unreachable, "#{peer} - Could not connect to web service - no response") if res.nil?
86-
fail_with(Failure::Unreachable, "#{peer} - Could not connect to web service - no response") unless res.code == 200
83+
fail_with(Failure::UnexpectedReply, "#{peer} - Could not connect to web service - no response") unless res.code == 200
8784

8885
json_post_data = JSON.pretty_generate(
8986
{

0 commit comments

Comments
 (0)