From 74f09aacd76eb62dd18a265b097378b55ae0fb50 Mon Sep 17 00:00:00 2001 From: Scott Moser Date: Thu, 21 Jun 2012 11:37:22 -0400 Subject: use yaml.safe_load rather than yaml.load LP: #1015818 --- ChangeLog | 1 + cloudinit/DataSourceMAAS.py | 2 +- cloudinit/UserDataHandler.py | 2 +- cloudinit/__init__.py | 4 ++-- cloudinit/util.py | 8 ++++---- 5 files changed, 9 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index 573e587c..1f1160d5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,7 @@ - support relative path in AuthorizedKeysFile (LP: #970071). - make apt-get update run with --quiet (suitable for logging) (LP: #1012613) - cc_salt_minion: use package 'salt-minion' rather than 'salt' (LP: #996166) + - use yaml.safe_load rather than yaml.load (LP: #1015818) 0.6.3: - add sample systemd config files [Garrett Holmstrom] - add Fedora support [Garrent Holstrom] (LP: #883286) diff --git a/cloudinit/DataSourceMAAS.py b/cloudinit/DataSourceMAAS.py index 61a0038f..e3e62057 100644 --- a/cloudinit/DataSourceMAAS.py +++ b/cloudinit/DataSourceMAAS.py @@ -293,7 +293,7 @@ if __name__ == "__main__": if args.config: import yaml with open(args.config) as fp: - cfg = yaml.load(fp) + cfg = yaml.safe_load(fp) if 'datasource' in cfg: cfg = cfg['datasource']['MAAS'] for key in creds.keys(): diff --git a/cloudinit/UserDataHandler.py b/cloudinit/UserDataHandler.py index ec914480..bf694a8e 100644 --- a/cloudinit/UserDataHandler.py +++ b/cloudinit/UserDataHandler.py @@ -94,7 +94,7 @@ def do_include(content, appendmsg): def explode_cc_archive(archive, appendmsg): - for ent in yaml.load(archive): + for ent in yaml.safe_load(archive): # ent can be one of: # dict { 'filename' : 'value', 'content' : 'value', 'type' : 'value' } # filename and type not be present diff --git a/cloudinit/__init__.py b/cloudinit/__init__.py index 85c6fd1b..6a1b46c5 100644 --- a/cloudinit/__init__.py +++ b/cloudinit/__init__.py @@ -421,7 +421,7 @@ class CloudInit: ## for now, not doing this as it seems somewhat circular ## as CloudConfig does that also, merging it with this cfg ## - # ccfg = yaml.load(self.cloud_config_str) + # ccfg = yaml.safe_load(self.cloud_config_str) # if ccfg is None: ccfg = {} # self.cfg = util.mergedict(ccfg, self.cfg) @@ -537,7 +537,7 @@ def get_base_cfg(cfg_path=None): def get_builtin_cfg(): - return(yaml.load(cfg_builtin)) + return(yaml.safe_load(cfg_builtin)) class DataSourceNotFoundException(Exception): diff --git a/cloudinit/util.py b/cloudinit/util.py index 47397418..84aae3ea 100644 --- a/cloudinit/util.py +++ b/cloudinit/util.py @@ -46,7 +46,7 @@ except ImportError: def read_conf(fname): try: stream = open(fname, "r") - conf = yaml.load(stream) + conf = yaml.safe_load(stream) stream.close() return conf except IOError as e: @@ -65,13 +65,13 @@ def get_base_cfg(cfgfile, cfg_builtin="", parsed_cfgs=None): kern_contents = read_cc_from_cmdline() if kern_contents: - kerncfg = yaml.load(kern_contents) + kerncfg = yaml.safe_load(kern_contents) # kernel parameters override system config combined = mergedict(kerncfg, syscfg) if cfg_builtin: - builtin = yaml.load(cfg_builtin) + builtin = yaml.safe_load(cfg_builtin) fin = mergedict(combined, builtin) else: fin = combined @@ -282,7 +282,7 @@ def read_seeded(base="", ext="", timeout=5, retries=10, file_retries=0): try: md_str = readurl(md_url, timeout=timeout) ud = readurl(ud_url, timeout=timeout) - md = yaml.load(md_str) + md = yaml.safe_load(md_str) return(md, ud) except urllib2.HTTPError as e: -- cgit v1.2.3