From 5005c8c8d3e1385084e3ff4d3f3133707522c17d Mon Sep 17 00:00:00 2001 From: Tom Clegg Date: Thu, 28 Mar 2019 16:01:28 -0400 Subject: [PATCH] 15044: Fix unnecessarily unsafe yaml load. ...and eliminate the associated warnings in test logs. Arvados-DCO-1.1-Signed-off-by: Tom Clegg --- build/run-tests.sh | 2 +- sdk/python/tests/run_test_server.py | 6 +++--- sdk/python/tests/test_arv_put.py | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/build/run-tests.sh b/build/run-tests.sh index 46e13b5568..087889145e 100755 --- a/build/run-tests.sh +++ b/build/run-tests.sh @@ -903,7 +903,7 @@ install_services/api() { # database, so that we can drop it. This assumes the current user # is a postgresql superuser. cd "$WORKSPACE/services/api" \ - && test_database=$(python -c "import yaml; print yaml.load(file('config/database.yml'))['test']['database']") \ + && test_database=$(python -c "import yaml; print yaml.safe_load(file('config/database.yml'))['test']['database']") \ && psql "$test_database" -c "SELECT pg_terminate_backend (pg_stat_activity.pid::int) FROM pg_stat_activity WHERE pg_stat_activity.datname = '$test_database';" 2>/dev/null mkdir -p "$WORKSPACE/services/api/tmp/pids" diff --git a/sdk/python/tests/run_test_server.py b/sdk/python/tests/run_test_server.py index 7b1f6059ae..a69a1d465e 100644 --- a/sdk/python/tests/run_test_server.py +++ b/sdk/python/tests/run_test_server.py @@ -738,7 +738,7 @@ def _getport(program): def _dbconfig(key): global _cached_db_config if not _cached_db_config: - _cached_db_config = yaml.load(open(os.path.join( + _cached_db_config = yaml.safe_load(open(os.path.join( SERVICES_SRC_DIR, 'api', 'config', 'database.yml'))) return _cached_db_config['test'][key] @@ -750,7 +750,7 @@ def _apiconfig(key): fullpath = os.path.join(SERVICES_SRC_DIR, 'api', 'config', f) if not required and not os.path.exists(fullpath): return {} - return yaml.load(fullpath) + return yaml.safe_load(fullpath) cdefault = _load('application.default.yml') csite = _load('application.yml', required=False) _cached_config = {} @@ -769,7 +769,7 @@ def fixture(fix): yaml_file = yaml_file[0:trim_index] except ValueError: pass - return yaml.load(yaml_file) + return yaml.safe_load(yaml_file) def auth_token(token_name): return fixture("api_client_authorizations")[token_name]["api_token"] diff --git a/sdk/python/tests/test_arv_put.py b/sdk/python/tests/test_arv_put.py index 01a52a5e66..540e06c6c6 100644 --- a/sdk/python/tests/test_arv_put.py +++ b/sdk/python/tests/test_arv_put.py @@ -859,7 +859,7 @@ class ArvPutIntegrationTest(run_test_server.TestCaseWithServers, if not mandatory and not os.path.exists(path): continue with open(path) as f: - rails_config = yaml.load(f.read()) + rails_config = yaml.safe_load(f.read()) for config_section in ['test', 'common']: try: key = rails_config[config_section]["blob_signing_key"] -- 2.39.5