Commit Graph

43 Commits

Author SHA1 Message Date
lhinds 2d2170273b Project Migration to PyCQA
This change rehomes the project to PyCQA[1] as reported to the
openstack-dev mailing list [1]

[0] https://github.com/PyCQA/bandit
[1] http://lists.openstack.org/pipermail/openstack-dev/2018-April/129386.html

Change-Id: I6aad329a60799ea24a3d9bc49e35c3c35ed9dc3b
2018-05-04 06:59:50 +02:00
Zuul 03b390b59b Merge "Allow specifying targets in ini file" 2017-12-07 17:41:28 +00:00
Zuul 3831b79051 Merge "Remove extra section from README.rst" 2017-11-27 05:34:27 +00:00
Marek Cermak 0b3cd391c1 Remove extra section from README.rst
Follow up patch for review/marek_cermak/formatter-custom.

Adressing comment by Gage Hugo: remove extra section from README.rst

Change-Id: I177861d404592ba4b9d7b953bbb983963d53b653
modified:   README.rst
2017-11-25 08:18:36 +00:00
Zuul 8f09d8b208 Merge "Custom formatter" 2017-11-24 16:25:22 +00:00
Marek Cermak d159335700 Custom formatter
Implements: custom formatter

Custom formatter can be used to output a machine-readable, easily
parsable and customizable format using set of predefined tags
to suite various needs.

Output string is formatted using python string.format() standards
and therefore provides familiar usage.

Usage: bandit --format custom [--msg-template MSG-TEMPLATE] targets

See bandit --help for additional information and list of available tags

modified:   bandit/cli/main.py
modified:   bandit/core/manager.py
modified:   README.rst
modified:   setup.cfg
new file:   bandit/formatters/custom.py

Change-Id: I900c9689cddb048db58608c443305e05e7a4be14
Signed-off-by: Marek Cermak <macermak@redhat.com>
2017-11-13 13:53:40 +01:00
Pavlo Shchelokovskyy 446e7f7249 Allow specifying targets in ini file
this patch makes 'targets' args optional and allows to specify them
in the ini file.
This makes it possible to keep most of bandit configuration right in
the ini file.
OpenStack projects can now populate their tox.ini with [bandit] section
and do 'bandit --ini {toxinidir}/tox.ini -r' almost uniformly
accross all projects.

Change-Id: Ia0153e0aaa602171690ca8f66635fbea69b1cfab
Closes-Bug: #1730307
2017-11-06 12:10:06 +02:00
Rajath Agasthya a98519927b Plugin to flag insecure hash functions created using hashlib.new()
Currently, insecure hash function usage by calling hashlib.md5()
is flagged in B303. But these hash functions can also be obtained using
hashlib.new(), by passing 'md4' or 'md5' as an argument. This plugin
checks such usage.

Change-Id: I8d368aea287e1287e5f638b48c4297d355037839
Closes-Bug: #1708582
2017-09-28 21:50:27 -07:00
loooosy 88a7f256d1 Optimize the link address
Use https instead of http to ensure the safety

Change-Id: I4df36b1f0a2b22fd7c9971b973cf1470400f8a4d
2017-04-10 05:36:41 +00:00
Eric Brown e40af23ff6 Blacklist call of ssl._create_unverified_context
The ssl._create_unverified_context creates a context for use with
such classes as HTTPSConnection which will do no certificate or
hostname verification. This should be flagged.

Change-Id: I326316e20ee11034c0a794f41c1bd8ae75720142
2017-03-20 12:19:36 -07:00
Eric Brown fbd4e83efe Yet Another Formatter (yaml)
This patch adds a yaml formatter to the output options of bandit.

Change-Id: Ibbe0cff062ce2c11138b746f95109f31de10f5b1
2017-02-27 16:23:17 -08:00
Eric Brown 0acf9f95db Fix up nits in the README and other files
* Consistently use single space after period, not double
* Keep line width at 80 where possible
* Replace Pythion 3.4 references with 3.5 since the gate no longer
  tests 3.4.

Change-Id: Ia6a1b9a5582f37e359b069b4a97f7c180e32ab3a
2017-01-05 15:12:11 -08:00
Jenkins 6539d68931 Merge "Show team and repo badges on README" 2016-12-12 17:10:04 +00:00
Eric Brown aae396e9bc Add capability to pipe a file into bandit
Allows someone to feed a file/text into bandit from a pipe rather
than just the 'targets' argument.

Usage example:
   cat examples/imports.py | bandit -

Change-Id: I1566684c0ae5476374960095816cb1720ff465a2
2016-11-28 23:00:45 -08:00
Flavio Percoco 784ff6a5eb Show team and repo badges on README
This patch adds the team's and repository's badges to the README file.
The motivation behind this is to communicate the project status and
features at first glance.

For more information about this effort, please read this email thread:

http://lists.openstack.org/pipermail/openstack-dev/2016-October/105562.html

To see an example of how this would look like check:

https://gist.github.com/7c8c96798a86412262178a8515075898

Change-Id: Ic4f702ac5e863c031e7a0856c87d1572cd8b823f
2016-11-28 08:58:15 -06:00
Tim Kelsey ee5ac9ff60 Adding "input()" to the blacklist calls list
Change-Id: Ia74f70334952dc913c9c6a3bf3c100c8fe649c3e
2016-09-20 11:19:43 +01:00
Grant Murphy 07f84cb5f5 Add check for httpoxy vulnerability
Change-Id: Ie366b110d33cb940ae176ccb87ef48e024868401
Closes-Bug: #1607907
2016-07-31 21:25:47 -07:00
Eric Brown 1310d18275 Allow output to default to stdout using argparse
The argparse module already has the capability to default to stdout
at CLI parameter definition time. This patch utilizes this and avoids
the opening of the output file by each formatter.

Change-Id: Ib1e89492558fe1fc06966711b6014bd5b86b84c8
2016-06-15 11:23:53 -07:00
Jamie Finnigan 0fabff579d Normalizing & editing command-line help text
This commit contains a number of relatively minor changes to the help
text displayed by Bandit when 'bandit -h' is executed.

It is an attempt to normalize (capitalization, formatting, and usage of
certain terms) and edit for clarity.

It also updates the README to include the new help text, and the test
that checks the README is up-to-date.

Change-Id: Ic583f891a295ac13339db1f65bcf38d66bd2abcd
2016-03-25 18:43:11 +00:00
Christopher J Schaefer cac2f22dee Added try_except_continue plugin
Along with a 'try, except, pass' check, we should also check for the
similar existance of 'try, except, continue', which raises the same
type of security implications, given the similar type of functionality.
Using 'continue' in place of 'pass' (inside a loop) currently allows
code to bypass the 'try, except, pass' warning.

Change-Id: I3e7ce037518875c5f5e46e26e1d72ef878f78a2f
2016-03-24 12:09:12 -05:00
Tim Kelsey c683327c97 Breaking up blacklist import IDs
This patch breaks up the blacklist imports sets to be one import
per ID (with the exception of things like pickle/cPickle etc).
This is done to give us more control over filtering stuff. It is
important to make any changes to IDs before 1.0 release as they
will form part of the 1.0 API contract (this renumbers some XML
IDs).

Change-Id: Ib575f6155a58f1795fe2c05fabdba4dbf1a89519
2016-03-18 11:54:51 +00:00
Eric Brown a61e3c4b85 Update command line help baseline report
The command line help for the baseline parameter is misleading.
The passed output has to be JSON, but the output formatters for
the result are different for baseline (another command line option).

Change-Id: I1f6d760af96b48472027dba94e585872768103c8
Closes-Bug: #1534358
2016-03-16 16:10:55 -07:00
Tim Kelsey 23b4f6a5c7 Updated legacy profile support
This patch updates the logic that handles profiles in preparation
for deprecation. If no profile name is given then we use
"exculded_tests" and "included_tests" to read in the test filters
("exclude" and "include" were already used). If a profile name is
given then we will read in the filter as before.

In addition, this makes -s/-t/-p no longer mutually exclusive. If
-t/-s are used on the CLI then they will update the profile filter
read from the config (legacy or otherwise). This is handy for
adding in extra tests during a one-off manual run.

Eventually -p will be deprecated in favour of using -c to pick
from a set of new style config files.

This also adds -s/-t to the config gen tool.

Change-Id: Ibf701f68106195f0153a37303fb1bdf5a8c2df9c
2016-03-14 10:44:19 +00:00
Travis McPeak 54a06aaebb Making config optional
This commit removes the requirement for having a config file.
Sometimes projects may want to use one to list out tests, define
a profile, or override a setting, but they are no longer required.

Change-Id: I6e467f58b2b27cae647901ac2c3f75a764e74c0c
2016-02-22 08:19:22 -08:00
Travis McPeak 49780b38af Adding JSON output for baseline results
This commit adds baseline functionality to the JSON formatter.
Issues will be listed as normal, however if multiple candidates
exist for an issue they'll be listed in 'candidates' with a value
of the list of prospective candidates.

Change-Id: Iaf5bcad52678f768375182175cde8d3efb17b6a3
2016-02-12 13:01:36 -08:00
Eric Brown bbe031350d Add test to compare help output with readme
This test ensures the contents of the readme no longer get out
of sync. It makes sure the output of 'bandit -h' is contained
in the readme.

Change-Id: I9b4302a18b724df43e0f6ee746a602bd7bcb0c0e
2016-02-11 00:06:54 -08:00
Eric Brown c0f31a8e6e Add blacklist plugins to help output
Currently none of the blacklist plugins get printed to the help
output. This patch appends them to the plugin list and updates
the README.

Closes-Bug: #1543882

Change-Id: I0eebf73b5a4f0a364ae204b69551d805e9aa3def
2016-02-09 18:01:52 -08:00
Eric Brown 74cf19517d Add PyPi badges
PyPi supports super cool badges in the README. They can show
latest version, # of downloads, docs, CI, code coverage, etc.

Change-Id: I2686e98fb8e047af4a587ebc0eeb7a09a3a0fe3d
2016-02-01 20:16:37 -08:00
Travis McPeak 0a28e1e885 Allow certain command line arguments to be passed from file
This commit allows the use of a .bandit file, which will be in
the ini format and used to pass command line arguments.  This is
useful for multiple projects which are running in the same gate,
want to be able to exclude different files per-project, and
aren't using tox.

Change-Id: I4256bdb7df2416f3cc01798882fb7e2e229790a3
2016-01-22 14:20:33 -08:00
Eric Brown f69066087a Update readme with latest changes
* screen formatter added
* test IDs added

Change-Id: I6ec66d8dbe931954632279444ee07735c8f49a2c
2016-01-14 14:31:21 -08:00
Eric Brown 9fe19996fe Update README with recent changes
Some outdated output of bandit -h was corrected.

Change-Id: Icedb6db9f19bad0d91e5f620d8246bb394f92ecb
2015-12-04 14:21:43 -08:00
Travis McPeak aa66e18d95 Adding command line option to exclude paths
This commit adds a command line option '--exclude' where comma
separated paths to exclude can be provided.  These will be
excluded in addition to whatever exclusions are defined in the
exclude section of the Bandit config.

Change-Id: I0ab992fea5b4683feb7af12fb80022012e417395
2015-10-14 06:57:45 +00:00
Jamie Finnigan 981ef46a46 Tweaks to #nosec (+ ignore flag, - dead constant)
Adds a flag '--ignore-nosec' to address the situation where a user is
auditing a code base and wants to see all identified issues, not just
those that haven't been nosec'd.

Also removes SKIP_FLAGS from core/constants.py, as that is no longer
used within the Bandit code base.

Change-Id: I1cef004660ff4abedb7128844cc0f26b9fdcda42
Closes-Bug: #1499467
2015-10-13 14:27:04 -04:00
xiabing.yao 6beab795a5 Update git clone repo
Change-Id: Idbc75546dd274288d7b3268dad934abf689ec8e8
2015-08-19 14:58:47 +08:00
Eric Brown 8cecf88564 Find bandit.yaml when in virtualenv
When running bandit without the '-c' parameter, it has the inability
to find bandit.yaml within a virtualenv.

This patch detects if running in a virtualenv and prepends that path
to an appropriate location of bandit.yaml (depending on platform).

Change-Id: I6b7faa8f4eefd91c9fff9da47dc1074075ad9494
Closes-Bug: #1484757
2015-08-14 11:01:56 -07:00
Dave Walker (Daviey) 2aba6b58f4 Add info: License, Source, Bugs and Docs to README
Release tooling expects Source and Bug information to be in
a certain format.  This adds it to the README.rst so this
can be processed.

In addition, this also adds a section to README.rst making
Bug reporting clearer.

Change-Id: I738d45e5a5c68066957f1fc2eae526fda0a055e5
Closes-Bug: #1480062
Signed-off-by: Dave Walker (Daviey) <email@daviey.com>
2015-08-05 22:21:44 +01:00
Dave Walker (Daviey) 80c7798e51 Actually default to /etc/ rather than just claim
Previously, we were claiming to default to
/etc/bandit/bandit.yaml for config location, but we were
neither installing a config there, nor trying to use it at
run time.

This makes use of appdirs for locations to use platform
declared config locations.  This also tries to install
the bandit.yaml in /etc/bandit.yaml. (Or on a local
pip install: /usr/local/etc/bandit/bandit.yaml)

The searched paths are also added to the README to help
avoid ambiguity.

Change-Id: I29a9ff738ebb402a069b9750d26e4c94f85e861a
Closes-Bug: #1475510
Signed-off-by: Dave Walker (Daviey) <email@daviey.com>
2015-08-05 18:54:56 +01:00
Eric Brown 1a419b4118 Update README with latest changes
The usage help for the bandit CLI has changed and needs updating.

* The help for --level had been updated and was not reflected in
  the README.
* The new option --confidence was missing

Change-Id: I3990ddd8548dc7903f6b0524fb2debdd3d0dc385
2015-08-05 07:05:46 -07:00
Brant Knudson 0052cd7476 Convert README to rst
PyPI showed the README.md without any formatting so it didn't
look good. Convert it to rst.

Change-Id: If5829f90059751146be85d3ed980df38fe865e0f
2015-08-04 09:34:55 -05:00
Travis McPeak f11e9b8ace Update the README file
The readme file has been updated to:
 - Be more concise up front about the purpose of Bandit
 - Reflect new install methods (from PyPI)
 - Update configuration section
 - Convert to markdown format (we had this anyway, it was just
called .rst for some reason)

Change-Id: Ibb39e9fe64760323240c1180d4df8c8e21349ecb
2015-05-06 16:45:15 -04:00
Travis McPeak e92174269b Update README.rst
The README doc was out of date in a couple of regards.  It still
showed the old way of calling bandit with 'find', rather than the
new way of just specifying a directory.  It also showed the old
style of decorators, rather than the new style which are just
marked with the AST node type that they check.

Change-Id: If32a7135c4ff4eb91506b5203f3f2af4f9b7935e
2015-03-31 09:15:54 -04:00
Rob Fletcher 0123f82d5c Adds JSON output functionality
Adds --format to support JSON format output

Change-Id: Ib35e9788e9076d3dd6158a8dfbd87a50c981ba56
2015-02-20 10:27:26 -08:00
Eric Brown 592174db8b Rename README.md to README.rst
PyPi expects README.rst.

Change-Id: I6c20a260499640e04b6d96506e1c223111955e12
2015-02-17 12:51:35 -08:00