Browse Source

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
ChangBo Guo(gcb) 1 year ago
parent
commit
4dde5f3cb2
3 changed files with 12 additions and 4 deletions
  1. 3
    3
      oslo_reports/tests/test_guru_meditation_report.py
  2. 3
    0
      test-requirements.txt
  3. 6
    1
      tox.ini

+ 3
- 3
oslo_reports/tests/test_guru_meditation_report.py View File

@@ -65,7 +65,7 @@ class GmrConfigFixture(fixture.Config):
65 65
 
66 66
         self.conf.set_override(
67 67
             'file_event_handler',
68
-            '/tmp/file',
68
+            '/specific/file',
69 69
             group='oslo_reports')
70 70
         self.conf.set_override(
71 71
             'file_event_handler_interval',
@@ -201,7 +201,7 @@ class TestGuruMeditationReport(base.BaseTestCase):
201 201
         version = FakeVersionObj()
202 202
         gmr.TextGuruMeditation.setup_autorun(version, conf=self.CONF)
203 203
         mock_setup_fh.assert_called_once_with(
204
-            '/tmp/file', 10, version, None, '/var/fake_log')
204
+            '/specific/file', 10, version, None, '/var/fake_log')
205 205
 
206 206
     @mock.patch('os.stat')
207 207
     @mock.patch('time.sleep')
@@ -215,7 +215,7 @@ class TestGuruMeditationReport(base.BaseTestCase):
215 215
             self.CONF.oslo_reports.file_event_handler_interval,
216 216
             version, None, self.CONF.oslo_reports.log_dir)
217 217
 
218
-        mock_stat.assert_called_once_with('/tmp/file')
218
+        mock_stat.assert_called_once_with('/specific/file')
219 219
         self.assertEqual(1, mock_thread.called)
220 220
 
221 221
     @mock.patch('oslo_utils.timeutils.utcnow',

+ 3
- 0
test-requirements.txt View File

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

+ 6
- 1
tox.ini View File

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

Loading…
Cancel
Save