Skip to content

Commit 9bf137b

Browse files
authored
fix tempfile vulnerability (Azure#38658)
* fix tempfile vulnerability
1 parent 0d3d678 commit 9bf137b

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

sdk/ml/azure-ai-ml/azure/ai/ml/_utils/_artifact_utils.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ def _redirect_artifacts_tool_path(self, organization: Optional[str]):
200200
url, headers=header
201201
)
202202
if response.status_code == 200:
203-
artifacts_tool_path = tempfile.mktemp() # nosec B306
203+
artifacts_tool_path = tempfile.mkdtemp() # nosec B306
204204
artifacts_tool_uri = response.json()["uri"]
205205
response = requests_pipeline.get(artifacts_tool_uri) # pylint: disable=too-many-function-args
206206
with zipfile.ZipFile(BytesIO(response.content)) as zip_file:
@@ -339,7 +339,7 @@ def get(
339339
os.unlink(check_sum_path)
340340
if artifact_package_path.exists():
341341
# Remove invalid artifact package to avoid affecting download artifact.
342-
temp_folder = tempfile.mktemp() # nosec B306
342+
temp_folder = tempfile.mkdtemp() # nosec B306
343343
os.rename(artifact_package_path, temp_folder)
344344
shutil.rmtree(temp_folder)
345345
# Download artifact
@@ -380,7 +380,7 @@ def set(
380380
:return artifact_package_path: Cache path of the artifact package
381381
:rtype: Path
382382
"""
383-
tempdir = tempfile.mktemp() # nosec B306
383+
tempdir = tempfile.mkdtemp() # nosec B306
384384
download_cmd = [
385385
shutil.which("az"),
386386
"artifacts",

0 commit comments

Comments
 (0)