Skip to content
This repository was archived by the owner on Mar 13, 2022. It is now read-only.

Commit bd9a852

Browse files
authored
Merge pull request #111 from xvello/xvello/safe_load
Use yaml.safe_load and yaml.safe_dump
2 parents 5c242ea + 13ff518 commit bd9a852

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

config/kube_config.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,7 @@ def get_with_name(self, name, safe=False):
493493
def _get_kube_config_loader_for_yaml_file(filename, **kwargs):
494494
with open(filename) as f:
495495
return KubeConfigLoader(
496-
config_dict=yaml.load(f),
496+
config_dict=yaml.safe_load(f),
497497
config_base_path=os.path.abspath(os.path.dirname(filename)),
498498
**kwargs)
499499

config/kube_config_test.py

+6-3
Original file line numberDiff line numberDiff line change
@@ -896,14 +896,16 @@ def test_ssl_with_relative_ssl_files(self):
896896
def test_load_kube_config(self):
897897
expected = FakeConfig(host=TEST_HOST,
898898
token=BEARER_TOKEN_FORMAT % TEST_DATA_BASE64)
899-
config_file = self._create_temp_file(yaml.dump(self.TEST_KUBE_CONFIG))
899+
config_file = self._create_temp_file(
900+
yaml.safe_dump(self.TEST_KUBE_CONFIG))
900901
actual = FakeConfig()
901902
load_kube_config(config_file=config_file, context="simple_token",
902903
client_configuration=actual)
903904
self.assertEqual(expected, actual)
904905

905906
def test_list_kube_config_contexts(self):
906-
config_file = self._create_temp_file(yaml.dump(self.TEST_KUBE_CONFIG))
907+
config_file = self._create_temp_file(
908+
yaml.safe_dump(self.TEST_KUBE_CONFIG))
907909
contexts, active_context = list_kube_config_contexts(
908910
config_file=config_file)
909911
self.assertDictEqual(self.TEST_KUBE_CONFIG['contexts'][0],
@@ -916,7 +918,8 @@ def test_list_kube_config_contexts(self):
916918
contexts)
917919

918920
def test_new_client_from_config(self):
919-
config_file = self._create_temp_file(yaml.dump(self.TEST_KUBE_CONFIG))
921+
config_file = self._create_temp_file(
922+
yaml.safe_dump(self.TEST_KUBE_CONFIG))
920923
client = new_client_from_config(
921924
config_file=config_file, context="simple_token")
922925
self.assertEqual(TEST_HOST, client.configuration.host)

0 commit comments

Comments
 (0)