Skip to content

Commit

Permalink
PyCQA#694 Bandit fails when using importlib with named arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
maciejstromich committed Mar 30, 2021
1 parent 6765a57 commit 402f761
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion bandit/core/blacklisting.py
Expand Up @@ -47,7 +47,10 @@ def blacklist(context, config):
# 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]
if context.call_args_count > 0:
name = context.call_args[0]
else:
name = context.call_keywords['name']
for check in blacklists[node_type]:
for qn in check['qualnames']:
if name is not None and fnmatch.fnmatch(name, qn):
Expand Down

0 comments on commit 402f761

Please sign in to comment.