fix: Replaced mktemp with a safer alternative mkstemp

* fix: Replaced `mktemp` with a safer alternative `mkstemp`

Signed-off-by: fazledyn-or <ataf@openrefactory.com>

---------

Signed-off-by: fazledyn-or <ataf@openrefactory.com>
Co-authored-by: Edward Zarecor <ezarecor@tcril.org>
Co-authored-by: Farhaan Bukhsh <farhaan@opencraft.com>
This commit is contained in:
Ataf Fazledin Ahamed
2025-01-22 23:48:31 +06:00
committed by GitHub
parent 0d042fb98b
commit 241997ec88

View File

@@ -19,7 +19,7 @@ import os
import re
import shutil
import tarfile
from tempfile import mkdtemp, mktemp
from tempfile import mkdtemp, mkstemp
from textwrap import dedent
from django.core.management.base import BaseCommand, CommandError
@@ -55,7 +55,9 @@ class Command(BaseCommand):
pipe_results = False
if filename is None:
filename = mktemp()
fd, filename = mkstemp()
os.close(fd)
os.unlink(filename)
pipe_results = True
export_course_to_tarfile(course_key, filename)