Use safe_load to load yaml

Replad `yaml.load` with `yaml.safe_load`
This commit is contained in:
Ganesh B. Nalawade 2017-09-14 21:36:56 +05:30 committed by Toshio Kuratomi
parent 5c029abac1
commit 8c3bf20a13
3 changed files with 3 additions and 3 deletions

View file

@ -355,7 +355,7 @@ def main():
elif payload and isinstance(payload, str) and HAS_YAML: elif payload and isinstance(payload, str) and HAS_YAML:
try: try:
# Validate YAML/JSON string # Validate YAML/JSON string
payload = json.dumps(yaml.load(payload)) payload = json.dumps(yaml.safe_load(payload))
except Exception as e: 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) 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: elif rest_type == 'xml' and HAS_LXML_ETREE:

View file

@ -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'") module.fail_json(msg="Python library Yaml is mandatory to use 'param_map'")
try: try:
param_map = yaml.load(param_map_json) param_map = yaml.safe_load(param_map_json)
except: except:
module.fail_json(msg="Unable to parse param_map information") module.fail_json(msg="Unable to parse param_map information")

View file

@ -78,7 +78,7 @@ def parse_cli(output, tmpl):
except ImportError as exc: except ImportError as exc:
raise AnsibleError(str(exc)) raise AnsibleError(str(exc))
spec = yaml.load(open(tmpl).read()) spec = yaml.safe_load(open(tmpl).read())
obj = {} obj = {}
for name, attrs in iteritems(spec['keys']): for name, attrs in iteritems(spec['keys']):