spraakbanken / metadata-api

REST-API that serves meta data for SB's corpora and lexicons
MIT License
1 stars 1 forks source link

Use yaml.safe_load() #19

Closed StaffanMelin closed 7 months ago

StaffanMelin commented 7 months ago

Applies to parse_yaml.py.

Change yaml.load(...) to res = yaml.safe_load(file_yaml), or change FullLoaded to SafeLoader.

Reason (from https://pyyaml.org/wiki/PyYAMLDocumentation#loading-yaml):

Warning: It is not safe to call yaml.load with any data received from an untrusted source! yaml.load is as powerful as pickle.load and so may call any Python function. Check the yaml.safe_load function though.

Now the question is if our yaml-files are safe? As they, if we are using yaml.load() can be used to "inject" Python code, and can be uploaded quite freely, it is better to be on the safe (!) side.