gitlab.bandit.B306

385
Download Count*
License

Use tempfile.NamedTemporaryFile instead. From the official Python documentation: THIS FUNCTION IS UNSAFE AND SHOULD NOT BE USED. The file name may refer to a file that did not exist at some point, but by the time you get around to creating it, someone else may have beaten you to the punch.

Run Locally

Run in CI

Defintion

rules:
  - id: bandit.B306
    pattern: tempfile.mktemp(...)
    message: >
      Use tempfile.NamedTemporaryFile instead. From the official Python
      documentation: THIS FUNCTION IS UNSAFE AND SHOULD

      NOT BE USED. The file name may refer to a file that did not exist at some point, but by the time you get around to creating

      it, someone else may have beaten you to the punch.
    metadata:
      cwe: "CWE-377: Insecure Temporary File"
      owasp: "A3: Sensitive Data Exposure"
      primary_identifier: bandit.B306
      secondary_identifiers:
        - name: Bandit Test ID B306
          type: bandit_test_id
          value: B306
      license: MIT
    languages:
      - python
    severity: ERROR