Merge "Fix the bandit security linter test"

This commit is contained in:
Zuul 2018-07-04 18:04:50 +00:00 committed by Gerrit Code Review
commit 9e61ad5405
3 changed files with 16 additions and 12 deletions

View File

@ -838,7 +838,7 @@ class Hosts(object):
entry.password = entry.password or default_password entry.password = entry.password or default_password
if default_realm and entry.username and '@' not in entry.username: if default_realm and entry.username and '@' not in entry.username:
entry.username = entry.username + '@' + default_realm entry.username = entry.username + '@' + default_realm
self._current = random.randint(0, len(self._entries) - 1) self._current = random.randint(0, len(self._entries) - 1) # nosec
@property @property
def current(self): def current(self):

View File

@ -426,8 +426,9 @@ class ConnectionContext(Connection):
LOG.exception(_LE("Fail to reset the connection, drop it")) LOG.exception(_LE("Fail to reset the connection, drop it"))
try: try:
self.connection.close() self.connection.close()
except Exception: except Exception as exc:
pass LOG.debug("pooled conn close failure (ignored): %s",
str(exc))
self.connection = self.connection_pool.create() self.connection = self.connection_pool.create()
finally: finally:
self.connection_pool.put(self.connection) self.connection_pool.put(self.connection)
@ -435,7 +436,8 @@ class ConnectionContext(Connection):
try: try:
self.connection.close() self.connection.close()
except Exception: except Exception:
pass LOG.debug("pooled conn close failure (ignored): %s",
str(exc))
self.connection = None self.connection = None
def __exit__(self, exc_type, exc_value, tb): def __exit__(self, exc_type, exc_value, tb):

18
tox.ini
View File

@ -1,6 +1,6 @@
[tox] [tox]
minversion = 2.0 minversion = 2.0
envlist = py35,py27,pep8,bandit envlist = py35,py27,pep8
[testenv] [testenv]
setenv = setenv =
@ -17,8 +17,10 @@ commands = stestr run --slowest {posargs}
[testenv:pep8] [testenv:pep8]
basepython = python3 basepython = python3
commands = flake8 commands =
deps = hacking<0.11,>=0.10.0 flake8
# run security linter
bandit -r oslo_messaging -x tests,_drivers/zmq_driver,_drivers/impl_zmq.py -n5
[testenv:cover] [testenv:cover]
basepython = python3 basepython = python3
@ -104,13 +106,13 @@ commands = {toxinidir}/setup-test-env-zmq-proxy.sh stestr run --slowest {posargs
basepython = python2.7 basepython = python2.7
commands = {toxinidir}/setup-test-env-zmq-pub-sub.sh stestr run --slowest {posargs:oslo_messaging.tests.functional} commands = {toxinidir}/setup-test-env-zmq-pub-sub.sh stestr run --slowest {posargs:oslo_messaging.tests.functional}
[testenv:bandit] [testenv:bandit]
# NOTE(kgiusti): This is required for the integration test job of the bandit
# project. Please do not remove.
basepython = python3 basepython = python3
deps = # skip ZeroMQ - it is deprecated
-c{env:UPPER_CONSTRAINTS_FILE:https://git.openstack.org/cgit/openstack/requirements/plain/upper-constraints.txt} commands = bandit -r oslo_messaging -x tests,_drivers/zmq_driver,_drivers/impl_zmq.py -n5
-r{toxinidir}/test-requirements.txt
-r{toxinidir}/requirements.txt
commands = bandit -r oslo_messaging -x tests -n5
[flake8] [flake8]
show-source = True show-source = True