From b75b9681a8c62c92b8f645763b74f0b22f69ed04 Mon Sep 17 00:00:00 2001 From: Michael DeHaan Date: Sat, 23 Feb 2013 13:34:14 -0500 Subject: [PATCH] more places to use yaml.safe_load --- lib/ansible/runner/filter_plugins/core.py | 2 +- lib/ansible/utils/module_docs.py | 2 +- library/git | 2 +- plugins/inventory/yaml.py | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/ansible/runner/filter_plugins/core.py b/lib/ansible/runner/filter_plugins/core.py index 51a1f827e59..484b059a555 100644 --- a/lib/ansible/runner/filter_plugins/core.py +++ b/lib/ansible/runner/filter_plugins/core.py @@ -26,6 +26,6 @@ class FilterModule(object): 'to_json': json.dumps, 'from_json': json.loads, 'to_yaml': yaml.safe_dump, - 'from_yaml': yaml.load, + 'from_yaml': yaml.safe_load, } diff --git a/lib/ansible/utils/module_docs.py b/lib/ansible/utils/module_docs.py index e8e5541716c..57d914cfbe4 100755 --- a/lib/ansible/utils/module_docs.py +++ b/lib/ansible/utils/module_docs.py @@ -45,7 +45,7 @@ def get_docstring(filename, verbose=False): for child in M.body: if isinstance(child, ast.Assign): if 'DOCUMENTATION' in (t.id for t in child.targets): - doc = yaml.load(child.value.s) + doc = yaml.safe_load(child.value.s) if 'EXAMPLES' in (t.id for t in child.targets): plainexamples = child.value.s[1:] # Skip first empty line except: diff --git a/library/git b/library/git index 020306bd1f2..d6307072b14 100644 --- a/library/git +++ b/library/git @@ -160,7 +160,7 @@ def get_head_branch(module, dest, remote): # Check if the .git is a file. If it is a file, it means that we are in a submodule structure. if os.path.isfile(repo_path): try: - gitdir = yaml.load(open(repo_path)).get('gitdir') + gitdir = yaml.safe_load(open(repo_path)).get('gitdir') # There is a posibility the .git file to have an absolute path. if os.path.isabs(gitdir): repo_path = gitdir diff --git a/plugins/inventory/yaml.py b/plugins/inventory/yaml.py index 4971d5e4681..c395a05a64d 100755 --- a/plugins/inventory/yaml.py +++ b/plugins/inventory/yaml.py @@ -226,7 +226,7 @@ base_dir = os.path.dirname(os.path.realpath(__file__)) hosts_file = os.path.join(base_dir, 'hosts.yml') with open(hosts_file) as f: - yaml_hosts = yaml.load( f.read() ) + yaml_hosts = yaml.safe_load( f.read() ) groups, all_hosts = parse_yaml(yaml_hosts)