Skip to content

Commit 0825546

Browse files
author
William Astorga
committed
fix: add extra checks for insecure_http_calls_in_python
1 parent 75fe34b commit 0825546

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

Splunk-TA-cisco-dnacenter/bin/cisco_dnac_api.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,8 @@ class Authentication(object):
157157
def __init__(self, base_url, verify=True):
158158
super(Authentication, self).__init__()
159159

160+
assert str(base_url).startswith("https"), "URL must be HTTPS"
160161
self._base_url = str(base_url)
161-
assert self._base_url.startswith("https"), "URL must be HTTPS"
162162

163163
self._single_request_timeout = 60
164164
self._verify = verify
@@ -357,18 +357,22 @@ def request(self, method, url, custom_refresh, **kwargs):
357357
abs_url, method, _headers=self.headers, **kwargs
358358
)
359359
)
360+
assert abs_url.startswith("https"), "URL must be HTTPS"
360361
response = self._req_session.request(method, abs_url, **kwargs)
361362
except IOError as e:
362363
if e.errno == errno.EPIPE:
363364
# EPIPE error
364365
try:
365366
c += 1
366367
self._helper.log_debug("Attempt {0}".format(c))
368+
assert abs_url.startswith("https"), "URL must be HTTPS"
367369
response = self._req_session.request(method, abs_url, **kwargs)
368370
except Exception as e:
369371
raise e
370372
else:
371373
raise e
374+
except AssertionError as e:
375+
raise e
372376
try:
373377
# Check the response code for error conditions
374378
assert response.status_code < 400

0 commit comments

Comments
 (0)