Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add timeout to requests calls #46

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions delinea/secrets/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ def get_access_grant(token_url, grant_request):
other than a valid Access Grant
"""

response = requests.post(token_url, grant_request)
response = requests.post(token_url, grant_request, timeout=60)

try: # TSS returns a 200 (OK) containing HTML for some error conditions
return json.loads(SecretServer.process(response).content)
Expand Down Expand Up @@ -301,14 +301,14 @@ def get_secret_json(self, id, query_params=None):
endpoint_url = f"{self.api_url}/secrets/{id}"

if query_params is None:
return self.process(requests.get(endpoint_url, headers=self.headers())).text
return self.process(requests.get(endpoint_url, headers=self.headers(), timeout=60)).text
else:
return self.process(
requests.get(
endpoint_url,
params=query_params,
headers=self.headers(),
)
timeout=60)
).text

def get_secret(self, id, fetch_file_attachments=True, query_params=None):
Expand Down Expand Up @@ -343,15 +343,15 @@ def get_secret(self, id, fetch_file_attachments=True, query_params=None):
endpoint_url = f"{self.api_url}/secrets/{id}/fields/{item['slug']}"
if query_params is None:
item["itemValue"] = self.process(
requests.get(endpoint_url, headers=self.headers())
requests.get(endpoint_url, headers=self.headers(), timeout=60)
)
else:
item["itemValue"] = self.process(
requests.get(
endpoint_url,
params=query_params,
headers=self.headers(),
)
timeout=60)
)
return secret

Expand Down Expand Up @@ -391,14 +391,14 @@ def search_secrets(self, query_params=None):
endpoint_url = f"{self.api_url}/secrets"

if query_params is None:
return self.process(requests.get(endpoint_url, headers=self.headers())).text
return self.process(requests.get(endpoint_url, headers=self.headers(), timeout=60)).text
else:
return self.process(
requests.get(
endpoint_url,
params=query_params,
headers=self.headers(),
)
timeout=60)
).text

def get_secret_ids_by_folderid(self, folder_id):
Expand All @@ -417,7 +417,7 @@ def get_secret_ids_by_folderid(self, folder_id):
params = {"filter.folderId": folder_id}
endpoint_url = f"{self.api_url}/secrets/search-total"
params["take"] = self.process(
requests.get(endpoint_url, params=params, headers=self.headers())
requests.get(endpoint_url, params=params, headers=self.headers(), timeout=60)
).text
response = self.search_secrets(query_params=params)

Expand Down
Loading