Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fuzzing #726

Merged
merged 5 commits into from
May 9, 2021
Merged

Fuzzing #726

merged 5 commits into from
May 9, 2021

Conversation

mykter
Copy link
Contributor

@mykter mykter commented Feb 25, 2021

Add a cargo-fuzz harness to make it easy to fuzz test the file parser for robustness and accuracy.

See fuzz/README.md for details.

With only a few seconds run time I found #725 - I suspect there are many more, if this kind of consistency bug is of interest.

When looking for panics only, after a few hours and 80 million executions, it found #727. There may be more to find after this one is fixed.

I am a novice Rust programmer - apologies in advance for blunders; any suggestions for better ways of doing things are welcome.

The only change to the existing tokei code is to make each LanguageType derive from Arbitrary. This makes it really easy to write a clean fuzzing harness. If it's desirable to avoid including this in release builds, I think we could conditionally compile it using cfg(fuzzing)?

See fuzz/README.md for details. Example bug: XAMPPRocky#725
Most of the config is to do with what files to parse, however
one setting - treat_doc_strings_as_comments - does impact parse_from_slice
@XAMPPRocky
Copy link
Owner

Thank you for your PR, and related issues! Overall this looks great! I'll give a more in depth review some time soon.

@XAMPPRocky
Copy link
Owner

XAMPPRocky commented May 9, 2021

Thank you for your PR, and congrats on your first contribution! 🎉 I'm going to merge this in for now, and we can improve it in-tree, as it looks mostly fine to me.

I suspect there are many more, if this kind of consistency bug is of interest.

Yes, I would like tokei to be consistent.

@XAMPPRocky XAMPPRocky merged commit 66967a1 into XAMPPRocky:master May 9, 2021
@mykter
Copy link
Contributor Author

mykter commented May 11, 2021

Great, I'll run the fuzzer again when the existing issues are fixed.

kornysietsma pushed a commit to kornysietsma/tokei that referenced this pull request Nov 16, 2022
* Add fuzzing support

See fuzz/README.md for details. Example bug: XAMPPRocky#725

* improve fuzz docs

* fuzzing: make relevant config part of input

Most of the config is to do with what files to parse, however
one setting - treat_doc_strings_as_comments - does impact parse_from_slice

* fuzzing: improve docs + config clarity

* fuzz/README.md: install instructions + another todo item
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants