Make sure temporary files are secure

Metadata

ID: python-security/mktemp

Language: Python

Severity: Notice

Category: Security

CWE: 377

Description

Using insecure temporary files makes your program vulnerable to attacks. The official Python documentation reports this module being vulnerable to attacks. Instead of mktemp, use the secure version mkstemp().

Learn More

Non-Compliant Code Examples

from tempfile import mktemp
mktemp(dir=self._tmp_dir)
import tempfile
tempfile.mktemp(dir=self._tmp_dir)

Compliant Code Examples

tempfile.mktemp(dir=self._tmp_dir)
import tempfile
tempfile.mkstemp(dir=self._tmp_dir)
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