mirror of
https://github.com/ansible/awx.git
synced 2026-03-01 08:48:46 -03:30
add timeouts to plugin backends
This commit is contained in:
@@ -107,7 +107,12 @@ def aim_backend(**kwargs):
|
|||||||
elif client_cert:
|
elif client_cert:
|
||||||
cert = create_temporary_fifo(client_cert.encode())
|
cert = create_temporary_fifo(client_cert.encode())
|
||||||
|
|
||||||
res = requests.get(request_url + request_qs, cert=cert, verify=verify)
|
res = requests.get(
|
||||||
|
request_url + request_qs,
|
||||||
|
timeout=30,
|
||||||
|
cert=cert,
|
||||||
|
verify=verify,
|
||||||
|
)
|
||||||
res.raise_for_status()
|
res.raise_for_status()
|
||||||
return res.json()['Content']
|
return res.json()['Content']
|
||||||
|
|
||||||
|
|||||||
@@ -108,7 +108,7 @@ def conjur_backend(**kwargs):
|
|||||||
if version:
|
if version:
|
||||||
path = '?'.join([path, version])
|
path = '?'.join([path, version])
|
||||||
|
|
||||||
resp = requests.get(path, **lookup_kwargs)
|
resp = requests.get(path, timeout=30, **lookup_kwargs)
|
||||||
resp.raise_for_status()
|
resp.raise_for_status()
|
||||||
return resp.text
|
return resp.text
|
||||||
|
|
||||||
|
|||||||
@@ -94,13 +94,14 @@ def kv_backend(**kwargs):
|
|||||||
# https://www.vaultproject.io/api/secret/kv/kv-v2.html#read-secret-version
|
# https://www.vaultproject.io/api/secret/kv/kv-v2.html#read-secret-version
|
||||||
response = sess.get(
|
response = sess.get(
|
||||||
'/'.join([url, mount_point, 'data'] + path).rstrip('/'),
|
'/'.join([url, mount_point, 'data'] + path).rstrip('/'),
|
||||||
params=params
|
params=params,
|
||||||
|
timeout=30
|
||||||
)
|
)
|
||||||
response.raise_for_status()
|
response.raise_for_status()
|
||||||
json = response.json()['data']
|
json = response.json()['data']
|
||||||
else:
|
else:
|
||||||
# https://www.vaultproject.io/api/secret/kv/kv-v1.html#read-secret
|
# https://www.vaultproject.io/api/secret/kv/kv-v1.html#read-secret
|
||||||
response = sess.get('/'.join([url, secret_path]).rstrip('/'))
|
response = sess.get('/'.join([url, secret_path]).rstrip('/'), timeout=30)
|
||||||
response.raise_for_status()
|
response.raise_for_status()
|
||||||
json = response.json()
|
json = response.json()
|
||||||
|
|
||||||
@@ -130,7 +131,8 @@ def ssh_backend(**kwargs):
|
|||||||
# https://www.vaultproject.io/api/secret/ssh/index.html#sign-ssh-key
|
# https://www.vaultproject.io/api/secret/ssh/index.html#sign-ssh-key
|
||||||
resp = sess.post(
|
resp = sess.post(
|
||||||
'/'.join([url, secret_path, 'sign', role]).rstrip('/'),
|
'/'.join([url, secret_path, 'sign', role]).rstrip('/'),
|
||||||
json=json
|
json=json,
|
||||||
|
timeout=30
|
||||||
)
|
)
|
||||||
resp.raise_for_status()
|
resp.raise_for_status()
|
||||||
return resp.json()['data']['signed_key']
|
return resp.json()['data']['signed_key']
|
||||||
|
|||||||
Reference in New Issue
Block a user