False positive: random.SystemRandom()

Bug #1422897 reported by Gabriel Hurley
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Bandit
Fix Released
Low
Tim Kelsey

Bug Description

Using random.SystemRandom() is actually a good and valid use. Bandit flags this (lowest severity) but it should in fact be ignored.

Simply importing random probably shouldn't be flagged at all (a linter will catch it if it's unused), and the test should check what functions and/or classes are being used from the random module.

Revision history for this message
Travis McPeak (travis-mcpeak) wrote :

Yeah, this test is very noisy. I think in the short term a viable solution is to use profiles which don't include this test.

Changed in bandit:
importance: Undecided → Low
status: New → Confirmed
Revision history for this message
Travis McPeak (travis-mcpeak) wrote :

Actually, more to your point - random.SystemRandom() is fine. That's a false positive every time.

Tim Kelsey (tim-kelsey)
Changed in bandit:
assignee: nobody → Tim Kelsey (tim-kelsey)
status: Confirmed → In Progress
Revision history for this message
Tim Kelsey (tim-kelsey) wrote :

for some reason the review isn't getting tagged in this bug, its here: https://review.openstack.org/#/c/202058/

Tim Kelsey (tim-kelsey)
Changed in bandit:
status: In Progress → Fix Committed
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to bandit (master)

Reviewed: https://review.openstack.org/202058
Committed: https://git.openstack.org/cgit/openstack/bandit/commit/?id=782ca732716c49f018aacbc7cdc14cbfd10c402b
Submitter: Jenkins
Branch: master

commit 782ca732716c49f018aacbc7cdc14cbfd10c402b
Author: Tim Kelsey <email address hidden>
Date: Wed Jul 15 12:42:18 2015 +0100

    Fixing up random to be less noisy

    This just targets specific functions within random, rather than
    the module itself. We use the blacklist calls stuff for this so
    there is now no need for a special plugin.

    Change-Id: Iecb4cd3d23040f2c4139f468109ddfbb209bbfa4
    Closes-Bug: 1422897

Revision history for this message
Eric Brown (ericwb) wrote :

Fix released in 0.13.0

Changed in bandit:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.