no timeout was given on call to external resource

このページは日本語には対応しておりません。随時翻訳に取り組んでいます。翻訳に関してご質問やご意見ございましたら、お気軽にご連絡ください。

Metadata

ID: python-security/requests-timeout

Language: Python

Severity: Error

Category: Security

CWE: 1088

Description

Access to remote resources should always use a timeout and appropriately handle the timeout and recovery. When using requests.get, requests.put, requests.patch, etc. - we should always use a timeout as an argument.

Learn More

Non-Compliant Code Examples

from requests import get, put
r = get(w, verify=False) # missing a timeout
r = get(w, verify=False, timeout=10)

def bla():
    r = get(w, verify=False)
import requests
r = requests.put(w, verify=False) # missing a timeout
import requests
r = requests.get(w, verify=False) # missing a timeout
r = requests.get(w, verify=False, timeout=10)



def foo():
    r = requests.get(w, verify=False) # missing a timeout
    
    if bar:
        r = requests.get(w, verify=False)

Compliant Code Examples

r = requests.put(w, verify=False)
import requests
r = requests.get(w, verify=False, timeout=5)
r = requests.get(w, verify=False, timeout=10)
https://static.datadoghq.com/static/images/logos/github_avatar.svg https://static.datadoghq.com/static/images/logos/vscode_avatar.svg jetbrains

Seamless integrations. Try Datadog Code Analysis

PREVIEWING: rtrieu/product-analytics-ui-changes