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