From 5258e6d52a65770f9c3a574c48d791207138cabf Mon Sep 17 00:00:00 2001 From: Brian Coca Date: Tue, 21 Feb 2017 16:46:59 -0500 Subject: [PATCH] use safe load instead fixes #21724 --- contrib/inventory/stacki.py | 2 +- lib/ansible/module_utils/aos.py | 2 +- lib/ansible/modules/cloud/cloudstack/cs_facts.py | 2 +- lib/ansible/modules/clustering/kubernetes.py | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/contrib/inventory/stacki.py b/contrib/inventory/stacki.py index db90df7befb..fd4cda54e44 100644 --- a/contrib/inventory/stacki.py +++ b/contrib/inventory/stacki.py @@ -170,7 +170,7 @@ def main(): for cfg_file in config_files: if os.path.isfile(cfg_file): stream = open(cfg_file, 'r') - config = yaml.load(stream) + config = yaml.safe_load(stream) break if not config: sys.stderr.write("No config file found at {}\n".format(config_files)) diff --git a/lib/ansible/module_utils/aos.py b/lib/ansible/module_utils/aos.py index 4f5b53af51d..806e5194d2c 100644 --- a/lib/ansible/module_utils/aos.py +++ b/lib/ansible/module_utils/aos.py @@ -132,7 +132,7 @@ def content_to_dict(module, content): # elif format in ['yaml', 'var']: try: - content_dict = yaml.load(content) + content_dict = yaml.safe_load(content) if not isinstance(content_dict, dict): raise diff --git a/lib/ansible/modules/cloud/cloudstack/cs_facts.py b/lib/ansible/modules/cloud/cloudstack/cs_facts.py index c5bbb39f820..801ae31520d 100644 --- a/lib/ansible/modules/cloud/cloudstack/cs_facts.py +++ b/lib/ansible/modules/cloud/cloudstack/cs_facts.py @@ -146,7 +146,7 @@ class CloudStackFacts(object): def _get_user_data_json(self): try: # this data come form users, we try what we can to parse it... - return yaml.load(self._fetch(CS_USERDATA_BASE_URL)) + return yaml.safe_load(self._fetch(CS_USERDATA_BASE_URL)) except: return None diff --git a/lib/ansible/modules/clustering/kubernetes.py b/lib/ansible/modules/clustering/kubernetes.py index 20514b0fe0a..5a56c8c6585 100644 --- a/lib/ansible/modules/clustering/kubernetes.py +++ b/lib/ansible/modules/clustering/kubernetes.py @@ -347,13 +347,13 @@ def main(): if inline_data: if not isinstance(inline_data, dict) and not isinstance(inline_data, list): - data = yaml.load(inline_data) + data = yaml.safe_load(inline_data) else: data = inline_data else: try: f = open(file_reference, "r") - data = [x for x in yaml.load_all(f)] + data = [x for x in yaml.safe_load_all(f)] f.close() if not data: module.fail_json(msg="No valid data could be found.")