-
Notifications
You must be signed in to change notification settings - Fork 685
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
Improve fuzzing coverage #1227
Improve fuzzing coverage #1227
Conversation
Codecov Report
@@ Coverage Diff @@
## dev #1227 +/- ##
==========================================
- Coverage 82.73% 82.72% -0.01%
==========================================
Files 159 159
Lines 20294 20294
Branches 7668 7671 +3
==========================================
- Hits 16791 16789 -2
- Misses 2882 2883 +1
- Partials 621 622 +1
Flags with carried forward coverage won't be shown. Click here to find out more.
|
cc46024
to
cc62f9f
Compare
@sashashura I'm contemplating if we should add all of the protocols to the fuzzing tests:
Is it worth adding this complexity? 🤔 |
Do you mean you have an idea adding something? Could you elaborate on that? Or is it about the changes done in the pull request? The current fuzzing covers all protocols already because it parses binary blobs. If a new protocol is added it is automatically discovered by fuzzer (New pcap test files are automatically added to the seed corpus by the build.sh script, but I don't know if oss-fuzz automatically picks them up or needs some manual bump to add them to the accumulated corpus files it maintains itself. Anyway at least eventually nothing stops the fuzzer from discovering the protocol after randomly mutating existing corpus files). This pull request however adds new fuzzers for ngpcap and snoop file containers. Each file format is fuzzed by a separately built fuzzer that is run in parallel by oss-fuzz, so it doesn't slow the fuzzing. The goal of the pull request is to improve the fuzzing coverage from the existing ~25% to 50-52%. More coverage - more fixed bugs. |
@sashashura I agree that we can add pcapng, but I doubt if we need to add snoop which is an old and rarely used format. Also, I wanted to ask about the main change in this PR which is in this file: The main concerns that I have with this PR:
|
If it is supported it should be fuzzed. Otherwise we should delete it.
Technically yes, but with a caveat. In ideal world we would have a set of pcap files that covered all possible cases, so fuzzing with pcapng would be unnecessary overlap. My coverage tests show however that the seed for pcap and the seed for pcapng have non-overlapping parts. But I hear you and made the changes to test only format parsing for .snoop files.
Yes, it is. It increases functions called by fuzzer from roughly 25% to 50%.
I think it is a misunderstanding that it brings contribution complexity. Fuzzing harness is essentially one more unit test. I have picked up many of the calls from existing tests. Expanding the fuzzing harness doesn't require anything neither from existing nor from new contributors. If a new Layer public method is added or even a whole new protocol is added, it doesn't require the contributor to add it to the harness. If the method signature changes (Side note, I think you don't allow changing of public API methods) existing unit tests will stop compiling and the contributor must update all places to make it compile anyway. If the function is deleted, the contributor is welcome to delete it from the fuzzer too. Most of the functions that are added are very simple as
I see your point and extracted the additional calls into a separate function to improve readability. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this pcap file relevant for this PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it improves the coverage. That was the case when code was reachable, but the fuzzer didn't manage to reach the code without help.
Thank you so much @sashashura for working on this! 🙏 🙏 |
Marked google/oss-fuzz#11198 as ready for review, but this pr wasn't merged to master yet. |
@sashashura I merged your PR to |
Improves fuzzing coverage and fixes a memory leak in SnoopFileReader.