summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Gaynor <alex.gaynor@gmail.com>2014-11-09 08:18:42 -0300
committerAlex Gaynor <alex.gaynor@gmail.com>2014-11-09 08:19:05 -0300
commit98d3de9f08886950dec4006fdce1b1d467a724d2 (patch)
tree78affc33ccbc633667bb6c5add7ba265f3d9a7ff
parentfc0b80ed3b80012ffef493ea287e88e5909a160c (diff)
downloados-client-config-98d3de9f08886950dec4006fdce1b1d467a724d2.tar.gz
Use yaml.safe_load instead of load.
yaml.load will execute arbitrary code. Also use context managers to ensure files are closed Change-Id: I704baa7916ee834c12821009d8e3029b1b8fa340
-rw-r--r--os_client_config/config.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/os_client_config/config.py b/os_client_config/config.py
index 925c23f..c711919 100644
--- a/os_client_config/config.py
+++ b/os_client_config/config.py
@@ -87,12 +87,14 @@ class OpenStackConfig(object):
def _load_config_file(self):
for path in self._config_files:
if os.path.exists(path):
- return yaml.load(open(path, 'r'))
+ with open(path, 'r') as f:
+ return yaml.safe_load(f)
def _load_vendor_file(self):
for path in self._vendor_files:
if os.path.exists(path):
- return yaml.load(open(path, 'r'))
+ with open(path, 'r') as f:
+ return yaml.safe_load(f)
def get_cache_max_age(self):
return self._cache_max_age