Use safe_load and safe_dump for all yaml calls
This commit is contained in:
parent
5c242ead60
commit
ebb49d02ed
@ -493,7 +493,7 @@ class ConfigNode(object):
|
|||||||
def _get_kube_config_loader_for_yaml_file(filename, **kwargs):
|
def _get_kube_config_loader_for_yaml_file(filename, **kwargs):
|
||||||
with open(filename) as f:
|
with open(filename) as f:
|
||||||
return KubeConfigLoader(
|
return KubeConfigLoader(
|
||||||
config_dict=yaml.load(f),
|
config_dict=yaml.safe_load(f),
|
||||||
config_base_path=os.path.abspath(os.path.dirname(filename)),
|
config_base_path=os.path.abspath(os.path.dirname(filename)),
|
||||||
**kwargs)
|
**kwargs)
|
||||||
|
|
||||||
|
|||||||
@ -896,14 +896,14 @@ class TestKubeConfigLoader(BaseTestCase):
|
|||||||
def test_load_kube_config(self):
|
def test_load_kube_config(self):
|
||||||
expected = FakeConfig(host=TEST_HOST,
|
expected = FakeConfig(host=TEST_HOST,
|
||||||
token=BEARER_TOKEN_FORMAT % TEST_DATA_BASE64)
|
token=BEARER_TOKEN_FORMAT % TEST_DATA_BASE64)
|
||||||
config_file = self._create_temp_file(yaml.dump(self.TEST_KUBE_CONFIG))
|
config_file = self._create_temp_file(yaml.safe_dump(self.TEST_KUBE_CONFIG))
|
||||||
actual = FakeConfig()
|
actual = FakeConfig()
|
||||||
load_kube_config(config_file=config_file, context="simple_token",
|
load_kube_config(config_file=config_file, context="simple_token",
|
||||||
client_configuration=actual)
|
client_configuration=actual)
|
||||||
self.assertEqual(expected, actual)
|
self.assertEqual(expected, actual)
|
||||||
|
|
||||||
def test_list_kube_config_contexts(self):
|
def test_list_kube_config_contexts(self):
|
||||||
config_file = self._create_temp_file(yaml.dump(self.TEST_KUBE_CONFIG))
|
config_file = self._create_temp_file(yaml.safe_dump(self.TEST_KUBE_CONFIG))
|
||||||
contexts, active_context = list_kube_config_contexts(
|
contexts, active_context = list_kube_config_contexts(
|
||||||
config_file=config_file)
|
config_file=config_file)
|
||||||
self.assertDictEqual(self.TEST_KUBE_CONFIG['contexts'][0],
|
self.assertDictEqual(self.TEST_KUBE_CONFIG['contexts'][0],
|
||||||
@ -916,7 +916,7 @@ class TestKubeConfigLoader(BaseTestCase):
|
|||||||
contexts)
|
contexts)
|
||||||
|
|
||||||
def test_new_client_from_config(self):
|
def test_new_client_from_config(self):
|
||||||
config_file = self._create_temp_file(yaml.dump(self.TEST_KUBE_CONFIG))
|
config_file = self._create_temp_file(yaml.safe_dump(self.TEST_KUBE_CONFIG))
|
||||||
client = new_client_from_config(
|
client = new_client_from_config(
|
||||||
config_file=config_file, context="simple_token")
|
config_file=config_file, context="simple_token")
|
||||||
self.assertEqual(TEST_HOST, client.configuration.host)
|
self.assertEqual(TEST_HOST, client.configuration.host)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user