From 8c3bf20a13a185e7c5c4bd0dee1bbe0b1ec2eab3 Mon Sep 17 00:00:00 2001 From: "Ganesh B. Nalawade" Date: Thu, 14 Sep 2017 21:36:56 +0530 Subject: [PATCH] Use safe_load to load yaml Replad `yaml.load` with `yaml.safe_load` --- lib/ansible/modules/network/aci/aci_rest.py | 2 +- lib/ansible/modules/network/aos/aos_blueprint_param.py | 2 +- lib/ansible/plugins/filter/network.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/ansible/modules/network/aci/aci_rest.py b/lib/ansible/modules/network/aci/aci_rest.py index 3df238a6b18..a4822ad4eb3 100644 --- a/lib/ansible/modules/network/aci/aci_rest.py +++ b/lib/ansible/modules/network/aci/aci_rest.py @@ -355,7 +355,7 @@ def main(): elif payload and isinstance(payload, str) and HAS_YAML: try: # Validate YAML/JSON string - payload = json.dumps(yaml.load(payload)) + payload = json.dumps(yaml.safe_load(payload)) except Exception as e: module.fail_json(msg='Failed to parse provided JSON/YAML content: %s' % to_text(e), exception=to_text(e), payload=payload) elif rest_type == 'xml' and HAS_LXML_ETREE: diff --git a/lib/ansible/modules/network/aos/aos_blueprint_param.py b/lib/ansible/modules/network/aos/aos_blueprint_param.py index 3f40cbc9158..d8a0f076d16 100644 --- a/lib/ansible/modules/network/aos/aos_blueprint_param.py +++ b/lib/ansible/modules/network/aos/aos_blueprint_param.py @@ -201,7 +201,7 @@ def get_collection_from_param_map(module, aos): module.fail_json(msg="Python library Yaml is mandatory to use 'param_map'") try: - param_map = yaml.load(param_map_json) + param_map = yaml.safe_load(param_map_json) except: module.fail_json(msg="Unable to parse param_map information") diff --git a/lib/ansible/plugins/filter/network.py b/lib/ansible/plugins/filter/network.py index 50952b4fa29..936aa960e87 100644 --- a/lib/ansible/plugins/filter/network.py +++ b/lib/ansible/plugins/filter/network.py @@ -78,7 +78,7 @@ def parse_cli(output, tmpl): except ImportError as exc: raise AnsibleError(str(exc)) - spec = yaml.load(open(tmpl).read()) + spec = yaml.safe_load(open(tmpl).read()) obj = {} for name, attrs in iteritems(spec['keys']):