Skip to content

Commit

Permalink
Update run.py (#3488)
Browse files Browse the repository at this point in the history
updated code to fix codeql  [SM03091] Insecure temporary file

Co-authored-by: Jayesh Tanna <[email protected]>
  • Loading branch information
jaga-work and jayesh-tanna authored Jan 16, 2025
1 parent a894fc3 commit dd47d1e
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions cli/monitoring/components/custom_preprocessing/src/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,10 @@ def preprocess(
# Data column is a list of objects, convert it into string because spark.read_json cannot read object
table = table.convert_column_types({"data": mltable.DataType.to_string()})

# Create MLTable in different location
save_path = tempfile.mktemp()
table.save(save_path)
# Use NamedTemporaryFile to create a secure temp file
with tempfile.NamedTemporaryFile(delete=False) as temp_file:
save_path = temp_file.name
table.save(save_path)

# Save preprocessed_data MLTable to temp location
des_path = preprocessed_input_data + "temp"
Expand Down

0 comments on commit dd47d1e

Please sign in to comment.