google / gofuzz

Fuzz testing for go.
Apache License 2.0
1.5k stars 119 forks source link

Support fuzzing unexported fields #63

Closed yanzhoupan closed 3 years ago

yanzhoupan commented 3 years ago

The current gofuzz only support fuzzing the exported fields (i.e. the fields that start with an uppercase letter), other fields are simply filtered out according to this line.

However, a lot of struct also contains un-exported fields (i.e. fields start with lowercase letters) and sometimes people want to do fuzzing on those structs. In this pr I fixed this problem by adding allowUnexportedFields to the fuzzer, which allows user to decide whether they want to include unexported fields while fuzzing. It is set to false by default. But it can be turned on with AllowUnexportedFields function.

Tests are also added.

google-cla[bot] commented 3 years ago

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

:memo: Please visit https://cla.developers.google.com/ to sign.

Once you've signed (or fixed any issues), please reply here with @googlebot I signed it! and we'll verify it.


What to do if you already signed the CLA

Individual signers
Corporate signers

ℹ️ Googlers: Go here for more info.

yanzhoupan commented 3 years ago

@googlebot I signed it!

lavalamp commented 3 years ago

LGTM, I'll double check the tests in a bit because the CI integration seems to be off or not working.

yanzhoupan commented 3 years ago

LGTM, I'll double check the tests in a bit because the CI integration seems to be off or not working.

Cool! Looking forward to my first contribution to google lol

lavalamp commented 3 years ago

Thanks for the change!