Skip to content

Commit

Permalink
ignore requests_mock for request-without-timeout
Browse files Browse the repository at this point in the history
this is a false positive, see PyCQA#996
  • Loading branch information
duncanmmacleod committed Aug 8, 2023
1 parent 3aaa2b0 commit bd861cc
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions bandit/plugins/request_without_timeout.py
Expand Up @@ -55,6 +55,7 @@ def request_without_timeout(context):
if (
"requests" in context.call_function_name_qual
and context.call_function_name in http_verbs
and context.call_function_name_qual.rsplit(".", 1)[0] != "requests_mock"
):
# check for missing timeout
if context.check_call_arg_value("timeout") is None:
Expand Down
5 changes: 5 additions & 0 deletions examples/requests-missing-timeout.py
Expand Up @@ -21,3 +21,8 @@
requests.head('https://gmail.com')
requests.head('https://gmail.com', timeout=None)
requests.head('https://gmail.com', timeout=5)

import requests_mock
requests_mock.get('https://gmail.com')
requests_mock.get('https://gmail.com', timeout=None)
requests_mock.get('https://gmail.com', timeout=5)
1 change: 1 addition & 0 deletions requirements.txt
Expand Up @@ -5,4 +5,5 @@ GitPython>=1.0.1 # BSD License (3 clause)
PyYAML>=5.3.1 # MIT
stevedore>=1.20.0 # Apache-2.0
colorama>=0.3.9;platform_system=="Windows" # BSD License (3 clause)
requests-mock # Apache-2.0
rich # MIT

0 comments on commit bd861cc

Please sign in to comment.