The tempfile module. mktemp() is deprecated and insecure (race condition between filename generation and open). Use NamedTemporaryFile, mkstemp, or TemporaryDirectory which atomically create the file.
.mkstemp().NamedTemporaryFile().mktemp().mktemp()Sinktempfile.mktemp(suffix='', prefix='tmp', dir=None) -> str
Returns a candidate temp file path without creating it. Insecure (TOCTOU) — finding whenever used.
.mkstemp()Sanitizertempfile.mkstemp(suffix=None, prefix=None, dir=None, text=False) -> (fd, path)
Atomically creates a temp file and returns an open fd. Safe replacement for mktemp.
return.NamedTemporaryFile()Sanitizertempfile.NamedTemporaryFile(mode='w+b', ...) -> _TemporaryFileWrapper
Context-managed temp file. Atomic creation. Safe.
return| FQN | Field | |
|---|---|---|
| tempfile | fqns[0] |
Wrong FQN → 0 findings. Verify with: change fqns to garbage → must produce 0 results.
from codepathfinder.go_rule import PyTempfile