Skip to content

Commit 9e9fb72

Browse files
authored
refactor file_path.chmod(0o600) (#2603)
1 parent a4e3c3d commit 9e9fb72

File tree

3 files changed

+15
-6
lines changed

3 files changed

+15
-6
lines changed

src/zenml/integrations/label_studio/annotators/label_studio_annotator.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -549,9 +549,13 @@ def populate_artifact_store_parameters(
549549
file_path = Path(
550550
secret_folder, "google_application_credentials.json"
551551
)
552-
with open(file_path, "w") as f:
552+
with os.fdopen(
553+
os.open(
554+
file_path, flags=os.O_RDWR | os.O_CREAT, mode=0o600
555+
),
556+
"w",
557+
) as f:
553558
f.write(json.dumps(gcp_credentials))
554-
file_path.chmod(0o600)
555559

556560
params.google_application_credentials = str(file_path)
557561

src/zenml/zen_stores/rest_zen_store.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -355,9 +355,10 @@ def validate_verify_ssl(
355355

356356
fileio.makedirs(str(secret_folder))
357357
file_path = Path(secret_folder, "ca_bundle.pem")
358-
with open(file_path, "w") as f:
358+
with os.fdopen(
359+
os.open(file_path, flags=os.O_RDWR | os.O_CREAT, mode=0o600), "w"
360+
) as f:
359361
f.write(verify_ssl)
360-
file_path.chmod(0o600)
361362
verify_ssl = str(file_path)
362363

363364
return verify_ssl

src/zenml/zen_stores/sql_zen_store.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -593,9 +593,13 @@ def _validate_url(cls, values: Dict[str, Any]) -> Dict[str, Any]:
593593
if content and not os.path.isfile(content):
594594
fileio.makedirs(str(secret_folder))
595595
file_path = Path(secret_folder, f"{key}.pem")
596-
with open(file_path, "w") as f:
596+
with os.fdopen(
597+
os.open(
598+
file_path, flags=os.O_RDWR | os.O_CREAT, mode=0o600
599+
),
600+
"w",
601+
) as f:
597602
f.write(content)
598-
file_path.chmod(0o600)
599603
values[key] = str(file_path)
600604

601605
values["url"] = str(sql_url)

0 commit comments

Comments
 (0)