When attempting to process a GitHub Workflow, the parsing logic incorrectly (?) interprets the property on of a workflow as a boolean value. For example, taking the following workflow:
name: Workflow
on:
push:
jobs:
job:
runs-on: ubuntu-latest
steps:
- run: echo "test"
Doing yaml.safe_load(workflow) will produce the following dict:
{
'name': 'Workflow',
True: {
'push': None
},
'jobs': {
'job': {
'runs-on': 'ubuntu-latest',
'steps': [{ 'run': 'echo "test"' }]
}
}
}
The key which should've been a string with value on is instead a boolean key with the value True. This happens in the resolve method, more specifically at this step:
|
for tag, regexp in resolvers + wildcard_resolvers: |
|
if regexp.match(value): |
|
return tag |
where the tag
tag:yaml.org,2002:bool is returned after the following regexp is matched to the value:
re.compile('^(?:yes|Yes|YES|no|No|NO\n |true|True|TRUE|false|False|FALSE\n |on|On|ON|off|Off|OFF)$', re.VERBOSE)
Any string on is converted to a boolean type which leads to this type of results. Is this intentional?
When attempting to process a GitHub Workflow, the parsing logic incorrectly (?) interprets the property
onof a workflow as a boolean value. For example, taking the following workflow:Doing
yaml.safe_load(workflow)will produce the following dict:The key which should've been a string with value
onis instead a boolean key with the valueTrue. This happens in theresolvemethod, more specifically at this step:pyyaml/lib/yaml/resolver.py
Lines 150 to 152 in 69c141a
where the tag
tag:yaml.org,2002:boolis returned after the following regexp is matched to the value:Any string
onis converted to a boolean type which leads to this type of results. Is this intentional?