Skip to content

Commit 241997e

Browse files
fazledyn-ore0dfarhaanbukhsh
authored
fix: Replaced mktemp with a safer alternative mkstemp
* fix: Replaced `mktemp` with a safer alternative `mkstemp` Signed-off-by: fazledyn-or <[email protected]> --------- Signed-off-by: fazledyn-or <[email protected]> Co-authored-by: Edward Zarecor <[email protected]> Co-authored-by: Farhaan Bukhsh <[email protected]>
1 parent 0d042fb commit 241997e

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

cms/djangoapps/contentstore/management/commands/export_olx.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
import re
2020
import shutil
2121
import tarfile
22-
from tempfile import mkdtemp, mktemp
22+
from tempfile import mkdtemp, mkstemp
2323
from textwrap import dedent
2424

2525
from django.core.management.base import BaseCommand, CommandError
@@ -55,7 +55,9 @@ def handle(self, *args, **options):
5555
pipe_results = False
5656

5757
if filename is None:
58-
filename = mktemp()
58+
fd, filename = mkstemp()
59+
os.close(fd)
60+
os.unlink(filename)
5961
pipe_results = True
6062

6163
export_course_to_tarfile(course_key, filename)

0 commit comments

Comments
 (0)