'NoneType' object has no attribute '__getitem__'

Bug #1481922 reported by Sean McGinnis
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Bandit
Fix Released
High
Sean McGinnis

Bug Description

Running bandit analysis against the cinder code base I am getting many of the following output:

[tester] ERROR Bandit internal error running: try_except_pass on file cinder/api/contrib/admin_actions.py at line 97: 'NoneType' object has no attribute '__getitem__'Traceback (most recent call last):
  File "/home/smcginnis/Documents/dev/repos/OpenStack/cinder/.tox/bandit/local/lib/python2.7/site-packages/bandit/core/tester.py", line 63, in run_tests
    result = test(context, test_config)
  File "/home/smcginnis/Documents/dev/repos/OpenStack/cinder/.tox/bandit/local/lib/python2.7/site-packages/bandit/plugins/try_except_pass.py", line 28, in try_except_pass
    if (not config['check_typed_exception'] and
TypeError: 'NoneType' object has no attribute '__getitem__'

It appears config is not being passed in by takes_config.

Other plugins using takes_config do not show this error, just try_except_pass. The other plugins also appear to be importing and declaring the decorator slightly different.

I found switching the import to match some of the other ones or keeping the import as is but adding parenthesis to the decorator makes the problem go away. Not sure how these really make a difference.

Using Python 2.7.6 on Ubuntu 14.01.

Changed in bandit:
assignee: nobody → Sean McGinnis (sean-mcginnis)
status: New → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to bandit (master)

Fix proposed to branch: master
Review: https://review.openstack.org/209679

Eric Brown (ericwb)
Changed in bandit:
importance: Undecided → High
Revision history for this message
Ian Cordasco (icordasc) wrote :

What version of bandit are you testing with?

Revision history for this message
Sean McGinnis (sean-mcginnis) wrote :

Appears to be 0.13.0.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Change abandoned on bandit (master)

Change abandoned by Sean McGinnis (<email address hidden>) on branch: master
Review: https://review.openstack.org/209679
Reason: Will be addressed by better handling of plugins missing from the config.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to bandit (master)

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

commit a3878eaf648f78446ee0814ebddf0f2fbd32b912
Author: Ian Cordasco <email address hidden>
Date: Thu Aug 6 10:41:50 2015 -0500

    Skip a test if it requires config but none is found

    If a user removes a section from their config, presume that they do not
    want to run it.

    Closes-bug: 1481922
    Change-Id: I5f8f4608dd337ac16d1bf822a8a98388c927677a

Changed in bandit:
status: In Progress → Fix Committed
Revision history for this message
Eric Brown (ericwb) wrote :

Fix released in 0.13.1

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.