Add bandit to pep8 job

Add the bandit security scanner to the pep8 job.
* convert assert statement to raise AssertionError
* skip B303

Change-Id: I0eb83dd6de80090562dd43bca4e5eb4e88e27bf9
This commit is contained in:
ChangBo Guo(gcb) 2017-12-07 14:04:56 +08:00
parent 38a98c3a01
commit 16a6db4e9e
3 changed files with 16 additions and 7 deletions

View File

@ -369,12 +369,13 @@ class ObjectVersionChecker(object):
for my_version, child_version in versions:
_my_version = vutils.convert_version_to_tuple(my_version)
_ch_version = vutils.convert_version_to_tuple(child_version)
assert (last_my_version < _my_version
and last_child_version <= _ch_version), \
('Object %s relationship '
'%s->%s for field %s is out of order') % (
obj_class.obj_name(), my_version,
child_version, field)
if not (last_my_version < _my_version
and last_child_version <= _ch_version):
raise AssertionError(('Object %s relationship %s->%s for '
'field %s is out of order') % (
obj_class.obj_name(),
my_version, child_version,
field))
last_my_version = _my_version
last_child_version = _ch_version

View File

@ -9,3 +9,6 @@ jsonschema<3.0.0,>=2.6.0 # MIT
mock>=2.0.0 # BSD
fixtures>=3.0.0 # Apache-2.0/BSD
# Bandit security code scanner
bandit>=1.1.0 # Apache-2.0

View File

@ -13,7 +13,12 @@ deps =
commands = python setup.py testr --slowest --testr-args='{posargs}'
[testenv:pep8]
commands = flake8
deps =
-r{toxinidir}/test-requirements.txt
commands =
flake8
# Run security linter
bandit -r oslo_versionedobjects tests -n5 --skip B303
[testenv:venv]
commands = {posargs}