Enforce use of safe yaml loader

Sorts runtime warning related to use of unsafe loading on yaml files.

Change-Id: I11f1332f34fe341b13100d8ae4c263cfbd5b90e0
This commit is contained in:
Sorin Sbarnea
2020-09-17 15:18:36 +01:00
parent dc942c06f1
commit e6b1354d91
3 changed files with 7 additions and 7 deletions

View File

@@ -287,8 +287,8 @@ def _main(args, config):
raise ElasticRecheckException(
"Channel Config must be specified in config file.")
channel_config = ChannelConfig(yaml.load(open(fp)))
msgs = MessageConfig(yaml.load(open(fp)))
channel_config = ChannelConfig(yaml.safe_load(open(fp)))
msgs = MessageConfig(yaml.safe_load(open(fp)))
if not args.noirc:
bot = RecheckWatchBot(

View File

@@ -69,7 +69,7 @@ def query(query_file_name, config=None, days=DEFAULT_NUMBER_OF_DAYS,
indexfmt=_config.es_index_format)
with open(query_file_name) as f:
query_file = yaml.load(f.read(), Loader=yaml.SafeLoader)
query_file = yaml.safe_load(f.read())
query = query_file['query']
r = es.search(query, days=days)

View File

@@ -54,8 +54,8 @@ class TestBot(unittest.TestCase):
allow_no_value=True)
_set_fake_config(self.fake_config)
config = er_conf.Config(config_obj=self.fake_config)
self.channel_config = bot.ChannelConfig(yaml.load(
open('recheckwatchbot.yaml'), Loader=yaml.SafeLoader))
self.channel_config = bot.ChannelConfig(yaml.safe_load(
open('recheckwatchbot.yaml')))
with mock.patch('launchpadlib.launchpad.Launchpad'):
self.recheck_watch = bot.RecheckWatch(
None,
@@ -100,8 +100,8 @@ class TestBotWithTestTools(tests.TestCase):
allow_no_value=True)
_set_fake_config(self.fake_config)
config = er_conf.Config(config_obj=self.fake_config)
self.channel_config = bot.ChannelConfig(yaml.load(
open('recheckwatchbot.yaml'), Loader=yaml.SafeLoader))
self.channel_config = bot.ChannelConfig(yaml.safe_load(
open('recheckwatchbot.yaml')))
with mock.patch('launchpadlib.launchpad.Launchpad'):
self.recheck_watch = bot.RecheckWatch(
None,