File size: 1,125 Bytes
8247f19 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | # Patch-overlapping Python context after the fix
## `pyanyapi/interfaces.py` — `class:YAMLInterface` (lines 272-279)
```python
class YAMLInterface(DictInterface):
_error_message = 'YAML data can not be parsed.'
def perform_parsing(self):
try:
return yaml.safe_load(self.content)
except yaml.error.YAMLError:
raise ResponseParseError(self._error_message, self.content)
```
## `pyanyapi/interfaces.py` — `function:YAMLInterface.perform_parsing` (lines 275-279)
```python
def perform_parsing(self):
try:
return yaml.safe_load(self.content)
except yaml.error.YAMLError:
raise ResponseParseError(self._error_message, self.content)
```
## `tests/test_parsers.py` — `function:test_yaml_parser_vulnerability` (lines 66-72)
```python
def test_yaml_parser_vulnerability():
"""
In case of usage of yaml.load `test` value will be equal to 0.
"""
parsed = YAMLParser({'test': 'container > test'}).parse('!!python/object/apply:os.system ["exit 0"]')
with pytest.raises(ResponseParseError):
parsed.test
```
|