Advertisement
Guest User

Bandit plugin

a guest
Jan 16th, 2015
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1. @checks_calls
  2. def subprocess_popen_with_shell_equals_true(context):
  3. if (context.call_function_name_qual == 'subprocess.Popen' or
  4. context.call_function_name_qual == 'utils.execute' or
  5. context.call_function_name_qual == 'utils.execute_with_timeout'):
  6. if context.check_call_arg_value('shell') == 'True':
  7.  
  8. return(bandit.ERROR, 'Popen call with shell=True '
  9. 'identified, security issue. %s' %
  10. context.call_args_string)
  11.  
  12.  
  13. @checks_calls
  14. def any_other_function_with_shell_equals_true(context):
  15. # Alerts on any function call that includes a shell=True parameter
  16. # (multiple 'helpers' with varying names have been identified across
  17. # various OpenStack projects).
  18. if context.call_function_name_qual != 'subprocess.Popen':
  19. if context.check_call_arg_value('shell') == 'True':
  20.  
  21. return(bandit.WARN, 'Function call with shell=True '
  22. 'parameter identified, possible security issue. %s' %
  23. context.call_args_string)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement