Skip to content

Commit c59b735

Browse files
authored
fix: Change yaml.load to yaml_parse as a best practice (#1951)
* change yaml.load to yaml.safe_load for the security best practice * use yaml_parse for consistant style
1 parent 68a3e1c commit c59b735

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

integration/helpers/base_test.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from integration.helpers.client_provider import ClientProvider
55
from integration.helpers.resource import generate_suffix, create_bucket, verify_stack_resources
66
from integration.helpers.yaml_utils import dump_yaml, load_yaml
7+
from samtranslator.yaml_helper import yaml_parse
78

89
try:
910
from pathlib import Path
@@ -293,7 +294,7 @@ def _fill_template(self, file_name):
293294
for key, _ in self.code_key_to_file.items():
294295
# We must double the {} to escape them so they will survive a round of unescape
295296
data = data.replace("${{{}}}".format(key), self.get_code_key_s3_uri(key))
296-
yaml_doc = yaml.load(data, Loader=yaml.FullLoader)
297+
yaml_doc = yaml_parse(data)
297298

298299
dump_yaml(updated_template_path, yaml_doc)
299300

integration/helpers/yaml_utils.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import yaml
22

3+
from samtranslator.yaml_helper import yaml_parse
4+
35

46
def load_yaml(file_path):
57
"""
@@ -17,7 +19,7 @@ def load_yaml(file_path):
1719
"""
1820
with open(file_path) as f:
1921
data = f.read()
20-
return yaml.load(data, Loader=yaml.FullLoader)
22+
return yaml_parse(data)
2123

2224

2325
def dump_yaml(file_path, yaml_doc):

0 commit comments

Comments
 (0)