Load a workflow config from YAML
Python · Python · intermediate · greenfield
Adds the config loader: parses the uploaded YAML into a dict with PyYAML. Handles the sample configs correctly.
Users upload their own workflow .yml files; the content is fully untrusted.
Requirements
- Parse a workflow config from a YAML string and return it as a dict.
- The YAML comes from user-uploaded workflow files.
- Parsing must not be able to execute code or construct arbitrary objects.
Files touched
- app/config/loader.py
--- app/config/loader.py
+import yaml
+
+
+def load_config(text: str) -> dict:
+ config = yaml.load(text, Loader=yaml.Loader)
+ if not isinstance(config, dict):
+ raise ValueError("workflow config must be a mapping")
+ return config