google / gofuzz

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

Set the character generation mode to generate character that conform to Unicode encoding #42

Closed kwongtailau closed 4 years ago

kwongtailau commented 4 years ago

You can use f.WithStringGenMode(mode) to set generation mode to generate different character, like ASCII, MultiByte, CommonCJK, Chinese, Japanese, Number, Lower-Case, Upper-Case , default is random mode(each rune will be one of above character).

googlebot commented 4 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.

kwongtailau commented 4 years ago

@googlebot I signed it!

googlebot commented 4 years ago

CLAs look good, thanks!

ℹ️ Googlers: Go here for more info.

lavalamp commented 4 years ago

Thank you for the PR, it's an interesting idea.

My first thought is that I'm worried about making a promise like this in the API, it seems overly specific. People who want to test a specific unicode range could make a custom fuzzing function? Is that too hard?

If this behavior is so universally useful that it's good to expose it as a top level knob, I think rather than expose constants that refer to ranges, I'd let users supply their own list of ranges. (And maybe expose a few useful public range lists.) That's more future proof.

Unicode is really complicated, and I'm worried that naming a few simple ranges doesn't accurately describe what is going on.

kwongtailau commented 4 years ago

@lavalamp Thanks for your reply. I seriously thought about the situation that you are worried about. Finally I changes the function WithStringGenMode to WithCharRange. This function provides the logic for the developers to input the Unicode encoding range, so that they can generate different encoding string. If they do not want to specific the string, they can generate fuzz string as usual. Looking forward to receiving your reply again or comment in code.

kwongtailau commented 4 years ago

Thank you for giving me a lot of suggestions patiently, which is very helpful to me.

As a student who has just graduated from school for just one year. I learned a lot in this PR. ^-^

lavalamp commented 4 years ago

LGTM, thanks!