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: mcretzman/DOCS-9337-add-cloud-info-byoti