From 241997ec88fb91f4fab70969941fe19a6cdd56fb Mon Sep 17 00:00:00 2001 From: Ataf Fazledin Ahamed Date: Wed, 22 Jan 2025 23:48:31 +0600 Subject: [PATCH] fix: Replaced `mktemp` with a safer alternative `mkstemp` * fix: Replaced `mktemp` with a safer alternative `mkstemp` Signed-off-by: fazledyn-or --------- Signed-off-by: fazledyn-or Co-authored-by: Edward Zarecor Co-authored-by: Farhaan Bukhsh --- .../contentstore/management/commands/export_olx.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/cms/djangoapps/contentstore/management/commands/export_olx.py b/cms/djangoapps/contentstore/management/commands/export_olx.py index 7561ebdc9b..68b291c013 100644 --- a/cms/djangoapps/contentstore/management/commands/export_olx.py +++ b/cms/djangoapps/contentstore/management/commands/export_olx.py @@ -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)