Skip to content

Commit 505659b

Browse files
committed
add a bandit environment to tox
This change is being proposed as part of the OpenStack Security Project working session at the Austin 2016 summit. It adds support for running the bandit[1] security linting tool against the python-openstackclient codebase. This change adds a targetted environment for bandit and also adds bandit as part of the pep8 job. The bandit configuration has been tailored to exclude tests that are currently producing warning against the codebase. These issues will be followed up with bug reports and patches. [1]: https://wiki.openstack.org/wiki/Security/Projects/Bandit Depends-On: Iccd81c17e84df03d249c1012277dad9cb68c5845 Change-Id: I691829c1224557d1d239c9f665ac539d0f13c4d3
1 parent 74162fa commit 505659b

2 files changed

Lines changed: 32 additions & 2 deletions

File tree

test-requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ testrepository>=0.0.18 # Apache-2.0/BSD
1717
testtools>=1.4.0 # MIT
1818
tempest-lib>=0.14.0 # Apache-2.0
1919
osprofiler>=1.3.0 # Apache-2.0
20+
bandit>=1.0.1 # Apache-2.0
2021

2122
# Install these to generate sphinx autodocs
2223
python-barbicanclient>=4.0.0 # Apache-2.0

tox.ini

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,36 @@ commands = ostestr {posargs}
1212
whitelist_externals = ostestr
1313

1414
[testenv:pep8]
15-
commands = flake8
15+
commands =
16+
flake8
17+
bandit -r openstackclient -x tests -s B105,B106,B107,B401,B404,B603,B606,B607,B110,B605,B101
18+
19+
[testenv:bandit]
20+
# This command runs the bandit security linter against the openstackclient
21+
# codebase minus the tests directory. Some tests are being excluded to
22+
# reduce the number of positives before a team inspection, and to ensure a
23+
# passing gate job for initial addition. The excluded tests are:
24+
# B105-B107: hardcoded password checks - likely to generate false positives
25+
# in a gate environment
26+
# B401: import subprocess - not necessarily a security issue; this plugin is
27+
# mainly used for penetration testing workflow
28+
# B603,B606: process without shell - not necessarily a security issue; this
29+
# plugin is mainly used for penetration testing workflow
30+
# B607: start process with a partial path - this should be a project level
31+
# decision
32+
# NOTE(elmiko): The following tests are being excluded specifically for
33+
# python-openstackclient, they are being excluded to ensure that voting jobs
34+
# in the project and in bandit integration tests continue to pass. These
35+
# tests have generated issue within the project and should be investigated
36+
# by the project.
37+
# B110: try, except, pass detected - possible security issue; this should be
38+
# investigated by the project for possible exploitation
39+
# B605: process with a shell - possible security issue; this should be
40+
# investigated by the project for possible exploitation
41+
# B101: use of assert - this code will be removed when compiling to optimized
42+
# byte code
43+
commands =
44+
bandit -r openstackclient -x tests -s B105,B106,B107,B401,B404,B603,B606,B607,B110,B605,B101
1645

1746
[testenv:functional]
1847
setenv = OS_TEST_PATH=./functional/tests
@@ -40,4 +69,4 @@ show-source = True
4069
exclude = .git,.tox,dist,doc,*openstack/common*,*lib/python*,*egg,build,tools
4170
# If 'ignore' is not set there are default errors and warnings that are set
4271
# Doc: http://flake8.readthedocs.org/en/latest/config.html#default
43-
ignore = __
72+
ignore = __

0 commit comments

Comments
 (0)