Jump to: navigation, search

Difference between revisions of "Security/Projects/Bandit"

m (Contributing)
m (Team)
Line 45: Line 45:
  
 
==Team==
 
==Team==
Bandit is a project from the [[Security#OpenStack_Security_Group|OpenStack Security Group]].
+
Bandit is a tool from the [https://security.openstack.org OpenStack Security] project.
  
 
Core project team:
 
Core project team:

Revision as of 04:07, 14 July 2015

Overview

Bandit is a security linter for Python source code, utilizing the ast module from the Python standard library.

The ast module is used to convert source code into a parsed tree of Python syntax nodes. Bandit allows users to define custom tests that are performed against those nodes. At the completion of testing, a report is generated that lists security issues identified within the target source code.

Bandit is currently a stand-alone tool which can be downloaded by end-users and run against arbitrary source code. As it matures and is proven to be useful, we see it being a possible addition to OpenStack CI gate tests with non-voting and eventually voting capabilities.

Bandit can be obtained by cloning the repository at https://git.openstack.org/openstack/bandit.git. The README.rst file contains documentation regarding installation, usage, and configuration.

Contributing

Bandit makes use of the OpenStack CI infrastructure provided through OpenStack:


An easy way to contribute is to write a plugin/test that will allow Bandit to identify more security issues. Extensions and improvements to the underlying framework are also welcomed, although we'll be attempting to maintain stability in the interface that is presented to plugins.

See Development Workflow for information on the general contribution/review workflow.

Gate Testing with Bandit

Bandit can help maintain the security of OpenStack projects when it's used as a gate test. Projects such as Keystone have created a gate test which runs Bandit to ensure that common security code mistakes are not introduced when code is modified.

To set up a Bandit gate test for an OpenStack project, follow these steps:

  1. Add a Bandit config for your project. For example, Keystone currently uses this one in their gate: bandit.yaml
  2. Add "bandit" (the package name on pypi) to the test-requirements.txt file. This file lists the requirements for creating the virtual environment Bandit runs in.
  3. Add a tox environment to run Bandit. Keystone's is here: tox.ini in the [testenv:bandit] section
  4. Add the Bandit job to the list of jobs for your project in OpenStack Infra. Keystone implemented this change here: jenkins/jobs/projects.yaml
  5. Add the Bandit gate to your project section in OpenStack Infra. For an example, here is Keystone's job: zuul/layout.yaml. Note: for Keystone Bandit is currently set up as non-voting. This means that failures in Bandit won't cause Jenkins to reject the change. This has the advantage that it will never cause your change to fail, but it also doesn't allow Bandit to prevent anything. To make the Bandit check voting set "voting: true".
  6. Modify the "check" section of your project in OpenStack infra to run Bandit as a check. For an example see this change: Keystone add Bandit check
  7. Run this way for a while and then make it voting!


Steps 1-3 should be done in one commit for your project, and steps 4-6 will be a separate commit for OpenStack Infra. If you have any questions or comments please contact tmcpeak in #openstack-security on Freenode IRC.

Profiles

By default Bandit runs all plugins that it finds in the plugins directory. While this may be useful for doing a thorough manual review, for use cases such as automation and gate testing, this is probably overkill. Luckily, Bandit allows a user to create profiles which run or exclude specific tests. For example, here is the profile that the Keystone gate uses: Keystone's Bandit Gate Profile .

Once a profile has been created, you can run it by using the "-c" command line option to point to the config file which contains your profile and "-p" to point to the specific profile you'd like to use.

TODO

TODO is now tracked using blueprints in Launchpad: https://blueprints.launchpad.net/bandit

Team

Bandit is a tool from the OpenStack Security project.

Core project team:

  • Jamie Finnigan (chair6)
  • Travis McPeak (tmcpeak)
  • Tim Kelsey (tkelsey)
  • Eric Brown (browne)
  • Ian Cordasco (sigmavirus24)