Skip to content

Commit

Permalink
Merge branch 'main' into py3.13
Browse files Browse the repository at this point in the history
  • Loading branch information
ericwb authored Oct 16, 2024
2 parents 17ffe7e + 8e6dc1b commit c4af4a8
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ repos:
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/asottile/reorder-python-imports
rev: v3.13.0
rev: v3.14.0
hooks:
- id: reorder-python-imports
args: [--application-directories, '.:src', --py38-plus]
Expand All @@ -18,7 +18,7 @@ repos:
- id: black
args: [--line-length=79, --target-version=py38]
- repo: https://github.com/asottile/pyupgrade
rev: v3.17.0
rev: v3.18.0
hooks:
- id: pyupgrade
args: [--py38-plus]
Expand Down
13 changes: 7 additions & 6 deletions bandit/plugins/request_without_timeout.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,7 @@ def request_without_timeout(context):
HTTPX_ATTRS = {"request", "stream", "Client", "AsyncClient"} | HTTP_VERBS
qualname = context.call_function_name_qual.split(".")[0]

if (
qualname == "requests"
and context.call_function_name in HTTP_VERBS
or qualname == "httpx"
and context.call_function_name in HTTPX_ATTRS
):
if qualname == "requests" and context.call_function_name in HTTP_VERBS:
# check for missing timeout
if context.check_call_arg_value("timeout") is None:
return bandit.Issue(
Expand All @@ -73,6 +68,12 @@ def request_without_timeout(context):
cwe=issue.Cwe.UNCONTROLLED_RESOURCE_CONSUMPTION,
text=f"Call to {qualname} without timeout",
)
if (
qualname == "requests"
and context.call_function_name in HTTP_VERBS
or qualname == "httpx"
and context.call_function_name in HTTPX_ATTRS
):
# check for timeout=None
if context.check_call_arg_value("timeout", "None"):
return bandit.Issue(
Expand Down
4 changes: 2 additions & 2 deletions tests/functional/test_functional.py
Original file line number Diff line number Diff line change
Expand Up @@ -368,8 +368,8 @@ def test_requests_ssl_verify_disabled(self):
def test_requests_without_timeout(self):
"""Test for the `requests` library missing timeouts."""
expect = {
"SEVERITY": {"UNDEFINED": 0, "LOW": 0, "MEDIUM": 36, "HIGH": 0},
"CONFIDENCE": {"UNDEFINED": 0, "LOW": 36, "MEDIUM": 0, "HIGH": 0},
"SEVERITY": {"UNDEFINED": 0, "LOW": 0, "MEDIUM": 25, "HIGH": 0},
"CONFIDENCE": {"UNDEFINED": 0, "LOW": 25, "MEDIUM": 0, "HIGH": 0},
}
self.check_example("requests-missing-timeout.py", expect)

Expand Down

0 comments on commit c4af4a8

Please sign in to comment.