Draft: Speeding up pysigma by using a faster yaml parser #133
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is currently a draft. Would close #128
The goal of this PR to make it possible to use a yaml parser that has the most intensive parts written in rust. This can considerable increase the speed of a large amount of yaml documents.
To install the rust parts you would need to install the library in the following way
pip install pysigma[rust]
. Since there may be slight shift in behaviour this shouldn't be made the standard behaviour. My suggestion is that once major version is introduced we can shift this around so thatryaml
becomes the default library used for parsing yaml.ryaml
which is the library written partially in rust does not havesafe_load
. But it is also not vulnerable to the same attacks that pyyaml was. To exemplify this I present the following poc taken from HackerOne.Create both of these files in the same directory. You also need to run an older version of pyyaml; say 3.13. pip install ryaml.
config.yaml
poc.py - need to use an older version of pyyaml 3.13
It's not vulnerable to the same attack, so it should be considered safe.
Some parts of the rust library was not fully compliant with the yaml spec, which is why some tests are still failing. Currently I'm tracking those required changes here > emmatyping/ryaml#3