Insecure temporary file or directory
Insecure ways of creating temporary files and directories can lead to race conditions (which can be exploited for denial of service attacks) and other security vulnerabilities such as privilege escalation.
def create_file_noncompliant(results):
    import tempfile
    # Noncompliant: uses a temporary file path to create a temporary file.
    filename = tempfile.mktemp()
    with open(filename, "w+") as f:
        f.write(results)
    print("Results written to", filename)
def create_temp_file_compliant(results):
    import tempfile
    # Compliant: uses the correct mechanism to create a temporary file.
    with tempfile.NamedTemporaryFile(mode="w+", delete=False) as f:
        f.write(results)
    print("Results written to", f.name)