Add bandit to pep8 job

Add the bandit security scanner to the pep8 job.
* skip B314,B405
* Don't use '/temp/file'

Change-Id: I5ae66767178d037d312eb2ab0374dd6f137ecc7b
This commit is contained in:
ChangBo Guo(gcb) 2017-12-07 13:43:21 +08:00
parent 80ec3ef091
commit 4dde5f3cb2
3 changed files with 12 additions and 4 deletions

View File

@ -65,7 +65,7 @@ class GmrConfigFixture(fixture.Config):
self.conf.set_override( self.conf.set_override(
'file_event_handler', 'file_event_handler',
'/tmp/file', '/specific/file',
group='oslo_reports') group='oslo_reports')
self.conf.set_override( self.conf.set_override(
'file_event_handler_interval', 'file_event_handler_interval',
@ -201,7 +201,7 @@ class TestGuruMeditationReport(base.BaseTestCase):
version = FakeVersionObj() version = FakeVersionObj()
gmr.TextGuruMeditation.setup_autorun(version, conf=self.CONF) gmr.TextGuruMeditation.setup_autorun(version, conf=self.CONF)
mock_setup_fh.assert_called_once_with( mock_setup_fh.assert_called_once_with(
'/tmp/file', 10, version, None, '/var/fake_log') '/specific/file', 10, version, None, '/var/fake_log')
@mock.patch('os.stat') @mock.patch('os.stat')
@mock.patch('time.sleep') @mock.patch('time.sleep')
@ -215,7 +215,7 @@ class TestGuruMeditationReport(base.BaseTestCase):
self.CONF.oslo_reports.file_event_handler_interval, self.CONF.oslo_reports.file_event_handler_interval,
version, None, self.CONF.oslo_reports.log_dir) version, None, self.CONF.oslo_reports.log_dir)
mock_stat.assert_called_once_with('/tmp/file') mock_stat.assert_called_once_with('/specific/file')
self.assertEqual(1, mock_thread.called) self.assertEqual(1, mock_thread.called)
@mock.patch('oslo_utils.timeutils.utcnow', @mock.patch('oslo_utils.timeutils.utcnow',

View File

@ -16,3 +16,6 @@ greenlet>=0.4.10 # MIT
coverage!=4.4,>=4.0 # Apache-2.0 coverage!=4.4,>=4.0 # Apache-2.0
reno>=2.5.0 # Apache-2.0 reno>=2.5.0 # Apache-2.0
# Bandit security code scanner
bandit>=1.1.0 # Apache-2.0

View File

@ -11,7 +11,12 @@ install_command = pip install {opts} {packages}
commands = python setup.py testr --slowest --testr-args='{posargs}' commands = python setup.py testr --slowest --testr-args='{posargs}'
[testenv:pep8] [testenv:pep8]
commands = flake8 deps =
-r{toxinidir}/test-requirements.txt
commands =
flake8
# Run security linter
bandit -r oslo_reports tests -n5 --skip B314,B405
[testenv:venv] [testenv:venv]
commands = {posargs} commands = {posargs}