Skip to content

Commit

Permalink
use json.load instead of eval
Browse files Browse the repository at this point in the history
  • Loading branch information
FxKu committed Oct 9, 2024
1 parent f6a9c6b commit a0f06ef
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion postgres-appliance/scripts/configure_spilo.py
Original file line number Diff line number Diff line change
Expand Up @@ -787,7 +787,7 @@ def write_log_environment(placeholders):
if not os.path.exists(log_env['LOG_ENV_DIR']):
os.makedirs(log_env['LOG_ENV_DIR'])

tags = eval(os.getenv('LOG_S3_TAGS'))
tags = json.loads(os.getenv('LOG_S3_TAGS'))
log_env['LOG_S3_TAGS'] = "&".join(f"{key}={os.getenv(value)}" for key, value in tags.items())

for var in ('LOG_TMPDIR',
Expand Down
3 changes: 2 additions & 1 deletion postgres-appliance/scripts/upload_pg_log_to_s3.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import boto3
import os
import json
import logging
import subprocess
import sys
Expand Down Expand Up @@ -66,7 +67,7 @@ def upload_to_s3(local_file_path):

try:
bucket.upload_file(local_file_path, key_name, Config=config,
ExtraArgs={'Tagging': eval(os.getenv('LOG_S3_TAGS'))})
ExtraArgs={'Tagging': json.loads(os.getenv('LOG_S3_TAGS'))})
except S3UploadFailedError as e:
logger.exception('Failed to upload the %s to the bucket %s under the key %s. Exception: %r',
local_file_path, bucket_name, key_name, e)
Expand Down

0 comments on commit a0f06ef

Please sign in to comment.