Skip to contentSkip to conversation

msg: use safe YAML loader

PATCH New Ross Burton 1 participant 1 message Dec 10, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 msg: use safe YAML loader

If using a YAML file in BB_LOGCONFIG, the unsafe loader is used and this causes a runtime warning:

YAMLLoadWarning: calling yaml.load() without Loader=... is deprecated, as the default Loader is unsafe. Please read https://msg.pyyaml.org/load
for full details.

As log configuration YAML is relatively simple we can just use safe_load().

---
 bitbake/lib/bb/msg.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
bitbake/lib/bb/msg.py +1 -1
index 6f17b6acc7..291b38ff7f 100644
@@ -278,7 +278,7 @@ def setLoggingConfig(defaultconfig, userconfigfile=None):
         with open(os.path.normpath(userconfigfile), 'r') as f:
             if userconfigfile.endswith('.yml') or userconfigfile.endswith('.yaml'):
                 import yaml
-                userconfig = yaml.load(f)
+                userconfig = yaml.safe_load(f)
             elif userconfigfile.endswith('.json') or userconfigfile.endswith('.cfg'):
                 import json
                 userconfig = json.load(f)
Signature · 1 line
2.25.1