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

net/netip: add fuzz test comparing with net.ParseIP #49367

Closed
FiloSottile opened this issue Nov 4, 2021 · 10 comments
Closed

net/netip: add fuzz test comparing with net.ParseIP #49367

FiloSottile opened this issue Nov 4, 2021 · 10 comments
Labels
FrozenDueToAge fuzz Issues related to native fuzzing support help wanted NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. Testing An issue that has been verified to require only test changes, not just a test failure.
Milestone

Comments

@FiloSottile
Copy link
Contributor

FiloSottile commented Nov 4, 2021

There is an excellent opportunity to write a fuzzer that compares the behaviors of net and netip, to find differences in parsing, serialization, validation, and IsFoo values. Although the internals are different, we probably want them to behave the same, and to document where they diverge intentionally.

It should also catch issues such as #49365.

/cc @katiehockman

@FiloSottile FiloSottile added Testing An issue that has been verified to require only test changes, not just a test failure. fuzz Issues related to native fuzzing support labels Nov 4, 2021
@FiloSottile FiloSottile added this to the Go1.18 milestone Nov 4, 2021
@thanm thanm added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Nov 5, 2021
@josharian
Copy link
Contributor

There's an existing go-fuzz based fuzzer that does this and more at github.com/inetaf/netaddr. We should port it.

@katiehockman
Copy link
Contributor

/cc @golang/fuzzing

@capnspacehook
Copy link

Is there still interest on getting this merged in during the freeze? I've never contributed to Go before but from what I understand, since this would just be adding a test it might still be acceptable to add now.

If so, I can work on this later this week.

@josharian
Copy link
Contributor

I believe it should be fine, but it would be good to get confirmation from @golang/release before starting. Thanks for volunteering!

@dmitshur
Copy link
Contributor

dmitshur commented Dec 8, 2021

Confirmed, it should be okay and helpful!

As I understand, fuzz tests don't run automatically during all.bash, so this is really low-risk for the stability of the tree and the release. But running them manually can help catch previously-undetected issues sooner.

@katiehockman
Copy link
Contributor

As I understand, fuzz tests don't run automatically during all.bash, so this is really low-risk for the stability of the tree and the release. But running them manually can help catch previously-undetected issues sooner.

That's not necessarily true. If there is any seed corpus (e.g. in the testdata directory for that fuzz test, or with calls to f.Add it would run with all.bash), those are run by default with go test. It won't fuzz by default though.
And even if there is no seed corpus, if anything fails before the f.Fuzz call, that would also fail all.bash.

That said, it is still a test, so I think it's still pretty low risk.

@capnspacehook
Copy link

Sweet, this should be a good way to get my feet wet contributing to Go :)

Speaking of the seed corpus, there is an existing corpus for this fuzz test at https://github.com/inetaf/netaddr-corpus, but I'm not sure if corpora should be included in the Go tree or not... Is there a policy for that?

@thepudds
Copy link
Contributor

thepudds commented Dec 9, 2021

FWIW, #31215 is an older proposal to create a new repository such as x/fuzzdata for holding fuzzing corpora for the standard library

Personally, I think it still makes sense, including gaining experience with the standard library is one way to help cmd/go fuzzing mature, including hopefully around basic corpus management.

@katiehockman
Copy link
Contributor

Speaking of the seed corpus, there is an existing corpus for this fuzz test at https://github.com/inetaf/netaddr-corpus, but I'm not sure if corpora should be included in the Go tree or not... Is there a policy for that?

There isn't such a policy for the standard library today.
For now, I suggest just writing and mailing the fuzz test without any seed corpus. It can always be added later, particularly when #48901 is done.

capnspacehook pushed a commit to capnspacehook/go that referenced this issue Dec 11, 2021
This is a pretty straight port of the fuzz test at https://github.com/inetaf/netaddr.

Fixes golang#49367
capnspacehook pushed a commit to capnspacehook/go that referenced this issue Dec 11, 2021
This is a pretty straight port of the fuzz test at https://github.com/inetaf/netaddr.

Fixes golang#49367
@gopherbot
Copy link

Change https://golang.org/cl/371055 mentions this issue: net/netip: add a fuzz test

capnspacehook pushed a commit to capnspacehook/go that referenced this issue Dec 12, 2021
This is a pretty straight port of the fuzz test at https://github.com/inetaf/netaddr.

Fixes golang#49367
@golang golang locked and limited conversation to collaborators Dec 20, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge fuzz Issues related to native fuzzing support help wanted NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. Testing An issue that has been verified to require only test changes, not just a test failure.
Projects
Status: No status
Development

Successfully merging a pull request may close this issue.

8 participants