summaryrefslogtreecommitdiff
path: root/keystoneclient/_discover.py
diff options
context:
space:
mode:
authorChristopher J Schaefer <cjschaef@us.ibm.com>2016-03-11 15:55:06 -0600
committerChristopher J Schaefer <cjschaef@us.ibm.com>2016-04-19 10:35:00 -0500
commitdbf4f3164655ec69a830ed87db0769f01ac1f720 (patch)
treecb93fd0797e8ea00d6faa94f01adddc6bd7083c1 /keystoneclient/_discover.py
parent91d1053f6811d454c538c85ea601dc700a56b4b3 (diff)
downloadpython-keystoneclient-dbf4f3164655ec69a830ed87db0769f01ac1f720.tar.gz
Removing bandit.yaml in favor of defaults
Removing old configuration options for build-in defaults of latest bandit functionality. Also, marking flagged items with _# nosec_ with a descriptive comment on why the code is acceptable as is. Co-Authored-By: Christopher J Schaefer <cjschaef@us.ibm.com> Co-Authored-By: Tom Cocozzello <tjcocozz@us.ibm.com> Change-Id: I138ebd46a8be195177361a9c3306bb70423b639d
Diffstat (limited to 'keystoneclient/_discover.py')
-rw-r--r--keystoneclient/_discover.py22
1 files changed, 14 insertions, 8 deletions
diff --git a/keystoneclient/_discover.py b/keystoneclient/_discover.py
index 9732793..568b169 100644
--- a/keystoneclient/_discover.py
+++ b/keystoneclient/_discover.py
@@ -42,28 +42,30 @@ def get_version_data(session, url, authenticated=None):
try:
body_resp = resp.json()
- except ValueError:
+ except ValueError: # nosec(cjschaef): raise a DiscoveryFailure below
pass
else:
# In the event of querying a root URL we will get back a list of
# available versions.
try:
return body_resp['versions']['values']
- except (KeyError, TypeError):
+ except (KeyError, TypeError): # nosec(cjschaef): attempt to return
+ # versions dict or query the endpoint or raise a DiscoveryFailure
pass
# Most servers don't have a 'values' element so accept a simple
# versions dict if available.
try:
return body_resp['versions']
- except KeyError:
+ except KeyError: # nosec(cjschaef): query the endpoint or raise a
+ # DiscoveryFailure
pass
# Otherwise if we query an endpoint like /v2.0 then we will get back
# just the one available version.
try:
return [body_resp['version']]
- except KeyError:
+ except KeyError: # nosec(cjschaef): raise a DiscoveryFailure
pass
err_text = resp.text[:50] + '...' if len(resp.text) > 50 else resp.text
@@ -77,14 +79,16 @@ def normalize_version_number(version):
# trim the v from a 'v2.0' or similar
try:
version = version.lstrip('v')
- except AttributeError:
+ except AttributeError: # nosec(cjschaef): 'version' is not a str, try a
+ # different type or raise a TypeError
pass
# if it's an integer or a numeric as a string then normalize it
# to a string, this ensures 1 decimal point
try:
num = float(version)
- except Exception:
+ except Exception: # nosec(cjschaef): 'version' is not a float, try a
+ # different type or raise a TypeError
pass
else:
version = str(num)
@@ -92,13 +96,15 @@ def normalize_version_number(version):
# if it's a string (or an integer) from above break it on .
try:
return tuple(map(int, version.split('.')))
- except Exception:
+ except Exception: # nosec(cjschaef): 'version' is not str (or an int),
+ # try a different type or raise a TypeError
pass
# last attempt, maybe it's a list or iterable.
try:
return tuple(map(int, version))
- except Exception:
+ except Exception: # nosec(cjschaef): 'version' is not an expected type,
+ # raise a TypeError
pass
raise TypeError(_('Invalid version specified: %s') % version)