Skip to content

Commit

Permalink
Fixed crash on dynamic import traversal (#369)
Browse files Browse the repository at this point in the history
* Fixed crash on dynamic import traversal

Signed-off-by: Antoine Salon <asalon@vmware.com>
  • Loading branch information
evqna authored and ericwb committed Aug 27, 2018
1 parent 679e883 commit 257b5dd
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion bandit/core/blacklisting.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,12 @@ def blacklist(context, config):
name = context.call_function_name_qual
# In the case the Call is an importlib.import, treat the first
# argument name as an actual import module name.
# Will produce None if argument is not a literal or identifier
if name in ["importlib.import_module", "importlib.__import__"]:
name = context.call_args[0]
for check in blacklists[node_type]:
for qn in check['qualnames']:
if fnmatch.fnmatch(name, qn):
if name is not None and fnmatch.fnmatch(name, qn):
return report_issue(check, name)

if node_type.startswith('Import'):
Expand Down

0 comments on commit 257b5dd

Please sign in to comment.