From 83b3317e8cce97c88a4081469c80ae8fcb6817c6 Mon Sep 17 00:00:00 2001 From: kateolenya Date: Fri, 11 Sep 2026 14:04:24 -0400 Subject: [PATCH] Use st2common meta safe YAML helpers in clone_action_files Switch from plain yaml.load and yaml.dump to the meta helpers for consistency. Refs #6393 --- CHANGELOG.rst | 1 + st2common/st2common/services/packs.py | 7 ++++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 107cf6a43f..ac090fbcb8 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -30,6 +30,7 @@ Fixed Changed ~~~~~~~ * Removed Python 3.8 and 3.9 from testing and CI/CD. + * Use the existing `st2common.constants.meta` safe YAML helpers in `clone_action_files` * Removed mongodb 7.0, rabbitmq 3.13 and redis 8.0 * Replaced deprecated `pkg_resources` module with `importlib-metadata` and `importlib-resources`. * Replaced abandoned `flex` module by `openapi-spec-validator` diff --git a/st2common/st2common/services/packs.py b/st2common/st2common/services/packs.py index ee2d937758..6e97c4a0ca 100644 --- a/st2common/st2common/services/packs.py +++ b/st2common/st2common/services/packs.py @@ -25,9 +25,10 @@ from six.moves import range from oslo_config import cfg import shutil -import yaml from st2common import log as logging +from st2common.constants.meta import yaml_safe_dump +from st2common.constants.meta import yaml_safe_load from st2common.content.utils import get_pack_base_path from st2common.exceptions.content import ResourceDiskFilesRemovalError from st2common.models.db.stormbase import UIDFieldMixin @@ -385,7 +386,7 @@ def clone_action_files(source_action_db, dest_action_db, dest_pack_base_path): ) with open(dest_metadata_file_path) as df: - doc = yaml.load(df, Loader=yaml.FullLoader) + doc = yaml_safe_load(df) doc["name"] = dest_action_db["name"] if "pack" in doc: @@ -393,7 +394,7 @@ def clone_action_files(source_action_db, dest_action_db, dest_pack_base_path): doc["entry_point"] = dest_entry_point with open(dest_metadata_file_path, "w") as df: - yaml.dump(doc, df, default_flow_style=False, sort_keys=False) + yaml_safe_dump(doc, stream=df, default_flow_style=False, sort_keys=False) def clone_action_db(source_action_db, dest_pack, dest_action):