Jump to: navigation, search

Security/Projects/Bandit

< Security‎ | Projects
Revision as of 19:41, 8 April 2015 by Travis McPeak (talk | contribs) (Gate Testing with Bandit)

Overview

Bandit provides a framework for performing security analysis of 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/stackforge/bandit.git. The README.md file contains documentation regarding installation, usage, and configuration.

Contributing

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


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 a test-requirement-bandit.txt file. This file is only needed temporarily because Bandit is not yet listed in global-requirements. Here's an example in Keystone: test-requirements-bandit.txt
  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 Bandit infra change


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.

TODO

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

Team

Bandit is a project from the OpenStack Security Group.

Core project team:

  • Jamie Finnigan (chair6)
  • Travis McPeak (tmcpeak)
  • Nathan Kinder (nkinder)
  • Tim Kelsey (tkelsey)
  • Lucas Fisher (ljfisher)