From 8ab2a197e8f8753cd4006103bd97de2e360a80b7 Mon Sep 17 00:00:00 2001 From: Tim Kelsey Date: Wed, 30 Mar 2016 13:49:24 +0100 Subject: [PATCH] Bandit test results New tests added to the upcoming bandit release now trip on finding try, except, continue. This patch adds nosec comments as needed to quiet unhelpful results. This was detected by bandit integration tests. Change-Id: I2632727cc62ae9a81d71c5b3cb2ed420d70f63bc --- keystone/catalog/backends/sql.py | 4 ++-- keystone/catalog/backends/templated.py | 2 +- keystone/token/persistence/backends/kvs.py | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/keystone/catalog/backends/sql.py b/keystone/catalog/backends/sql.py index bd92f10794..ee7e66ba5f 100644 --- a/keystone/catalog/backends/sql.py +++ b/keystone/catalog/backends/sql.py @@ -296,7 +296,7 @@ class Catalog(catalog.CatalogDriverV8): url = formatted_url else: continue - except exception.MalformedEndpoint: + except exception.MalformedEndpoint: # nosec(tkelsey) continue # this failure is already logged in format_url() region = endpoint['region_id'] @@ -358,7 +358,7 @@ class Catalog(catalog.CatalogDriverV8): endpoint['url'] = formatted_url else: continue - except exception.MalformedEndpoint: + except exception.MalformedEndpoint: # nosec(tkelsey) # this failure is already logged in format_url() continue diff --git a/keystone/catalog/backends/templated.py b/keystone/catalog/backends/templated.py index 2e80fd3272..60b6c874a3 100644 --- a/keystone/catalog/backends/templated.py +++ b/keystone/catalog/backends/templated.py @@ -236,7 +236,7 @@ class Catalog(core.Driver): silent_keyerror_failures=silent_keyerror_failures) if formatted_value: service_data[k] = formatted_value - except exception.MalformedEndpoint: + except exception.MalformedEndpoint: # nosec(tkelsey) continue # this failure is already logged in format_url() catalog[region][service] = service_data diff --git a/keystone/token/persistence/backends/kvs.py b/keystone/token/persistence/backends/kvs.py index 2625273963..9659853b08 100644 --- a/keystone/token/persistence/backends/kvs.py +++ b/keystone/token/persistence/backends/kvs.py @@ -170,7 +170,7 @@ class Token(token.persistence.TokenDriverV8): for item in token_list: try: item_id, expires = self._format_token_index_item(item) - except (ValueError, TypeError): + except (ValueError, TypeError): # nosec(tkelsey) # NOTE(morganfainberg): Skip on expected errors # possibilities from the `_format_token_index_item` method. continue @@ -334,7 +334,7 @@ class Token(token.persistence.TokenDriverV8): for item in token_list: try: token_id, expires = self._format_token_index_item(item) - except (TypeError, ValueError): + except (TypeError, ValueError): # nosec(tkelsey) # NOTE(morganfainberg): Skip on expected error possibilities # from the `_format_token_index_item` method. continue @@ -344,7 +344,7 @@ class Token(token.persistence.TokenDriverV8): try: token_ref = self.get_token(token_id) - except exception.TokenNotFound: + except exception.TokenNotFound: # nosec(tkelsey) # NOTE(morganfainberg): Token doesn't exist, skip it. continue if token_ref: