Use yaml.safe_load() instead of yaml.load()
yaml.load() provides the ability to construct an arbitrary python object
that may be dangerous. yaml.safe_load() limits this ability to simple
python objects like integers or lists.
ref: https://en.wikipedia.org/wiki/YAML#Security
Change-Id: I9c28c25f4265fb691d39e72e20ef9c99f5538bf5
diff --git a/functional/test_resource_group.py b/functional/test_resource_group.py
index e40376c..1e9edd5 100644
--- a/functional/test_resource_group.py
+++ b/functional/test_resource_group.py
@@ -419,7 +419,7 @@
super(ResourceGroupAdoptTest, self).setUp()
def _yaml_to_json(self, yaml_templ):
- return yaml.load(yaml_templ)
+ return yaml.safe_load(yaml_templ)
def test_adopt(self):
data = {
@@ -455,7 +455,7 @@
}
},
"environment": {"parameters": {}},
- "template": yaml.load(self.main_template)
+ "template": yaml.safe_load(self.main_template)
}
stack_identifier = self.stack_adopt(
adopt_data=json.dumps(data))
@@ -556,7 +556,7 @@
Simple rolling update with no conflict in batch size
and minimum instances in service.
"""
- updt_template = yaml.load(copy.deepcopy(self.template))
+ updt_template = yaml.safe_load(copy.deepcopy(self.template))
grp = updt_template['resources']['random_group']
policy = grp['update_policy']['rolling_update']
policy['min_in_service'] = '1'
@@ -575,7 +575,7 @@
Simple rolling update replace with no conflict in batch size
and minimum instances in service.
"""
- updt_template = yaml.load(copy.deepcopy(self.template))
+ updt_template = yaml.safe_load(copy.deepcopy(self.template))
grp = updt_template['resources']['random_group']
policy = grp['update_policy']['rolling_update']
policy['min_in_service'] = '1'
@@ -594,7 +594,7 @@
Simple rolling update with reduced size.
"""
- updt_template = yaml.load(copy.deepcopy(self.template))
+ updt_template = yaml.safe_load(copy.deepcopy(self.template))
grp = updt_template['resources']['random_group']
policy = grp['update_policy']['rolling_update']
policy['min_in_service'] = '1'
@@ -613,7 +613,7 @@
Simple rolling update with increased size.
"""
- updt_template = yaml.load(copy.deepcopy(self.template))
+ updt_template = yaml.safe_load(copy.deepcopy(self.template))
grp = updt_template['resources']['random_group']
policy = grp['update_policy']['rolling_update']
policy['min_in_service'] = '1'
@@ -632,7 +632,7 @@
Update with capacity adjustment with enough resources.
"""
- updt_template = yaml.load(copy.deepcopy(self.template))
+ updt_template = yaml.safe_load(copy.deepcopy(self.template))
grp = updt_template['resources']['random_group']
policy = grp['update_policy']['rolling_update']
policy['min_in_service'] = '8'
@@ -652,7 +652,7 @@
Rolling update with capacity adjustment due to conflict in
batch size and minimum instances in service.
"""
- updt_template = yaml.load(copy.deepcopy(self.template))
+ updt_template = yaml.safe_load(copy.deepcopy(self.template))
grp = updt_template['resources']['random_group']
policy = grp['update_policy']['rolling_update']
policy['min_in_service'] = '8'
@@ -671,7 +671,7 @@
Rolling Update with a huge batch size(more than
current size).
"""
- updt_template = yaml.load(copy.deepcopy(self.template))
+ updt_template = yaml.safe_load(copy.deepcopy(self.template))
grp = updt_template['resources']['random_group']
policy = grp['update_policy']['rolling_update']
policy['min_in_service'] = '0'
@@ -689,7 +689,7 @@
Rolling Update with a huge number of minimum instances
in service.
"""
- updt_template = yaml.load(copy.deepcopy(self.template))
+ updt_template = yaml.safe_load(copy.deepcopy(self.template))
grp = updt_template['resources']['random_group']
policy = grp['update_policy']['rolling_update']
policy['min_in_service'] = '20'