Make sure temporary files are secure

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

Metadata

ID: python-security/mktemp

Language: Python

Severity: Notice

Category: Security

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