-
Notifications
You must be signed in to change notification settings - Fork 17.7k
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
image: add sample fuzz tests for prototype of "fuzzing as a first class citizen" #30979
Comments
Agree. |
I'm happy to see that progress is being made, and I am willing to prepare these next CLs too, if that's okay with everyone. It seems like of the three packages listed in this issue, First, there are two fuzz functions: a Second, @dvyukov, what exactly do you mean by "open-code" all comparisons? Explicitly writing loops and such, and avoiding |
I named them after the actual Encode/Decode functions. Seems fine to me.
Using
|
Regarding this piece about
It seems image/src/gif/write_test.go has some logic around doing comparison, including in |
I would like to bring to your attention the fact that building Apart from I imagine that for people who do not use two different Go trees (one for general work using Go and another for working on Go itself), this is not a problem at all, but if you are like me and use different trees, you might hit this, and be surprised or confused. I am hoping that this post helps with this potential confusion. |
Change https://golang.org/cl/168558 mentions this issue: |
Add a Fuzz function to package png, under the gofuzz build tag. This function is based on the png/png.go code, from github.com/dvyukov/go-fuzz-corpus, modified to use direct comparison of image bounds rather than reflect.DeepEqual. Updates #30979 Updates #19109 Change-Id: Idb86e7ded0c2d78e6cadbeda84c7b1f35b8c579c Reviewed-on: https://go-review.googlesource.com/c/go/+/168558 Reviewed-by: thepudds <thepudds1460@gmail.com> Reviewed-by: Dmitry Vyukov <dvyukov@google.com> Run-TryBot: Dmitry Vyukov <dvyukov@google.com>
@katiehockman @thepudds What is the status of this issue considering the active work on fuzzing? Thanks. |
Summary
As a follow-up to #30719 and in support of the proposal to "make fuzzing a first class citizen" in #19109, the suggestion here is to add
Fuzz
functions for the following three standard library packages:image/jpeg
, using https://github.com/dvyukov/go-fuzz-corpus/blob/master/jpeg/jpeg.goimage/png
, using https://github.com/dvyukov/go-fuzz-corpus/blob/master/png/png.goimage/gif
, using a modified https://github.com/dvyukov/go-fuzz-corpus/blob/master/gif/gif.go (some additional discussion below).Note that this issue is solely about the
Fuzz
functions themselves, and this issue does not cover checking in any resulting fuzzing corpus (which is likely going to be a separate repository such asgolang/x/corpus
orgolang.org/x/fuzz
or perhaps using oss-fuzz; the intent is to discuss that aspect separately in a follow-up issue).Background
See the "Background" section of #30719 or #19109 (comment).
Additional Details
Following the pattern set by #30719 and https://golang.org/cl/167097, the following are likely true for how to proceed here:
// +build gofuzz
fuzz.go
Fuzz
functions guarded by a build tag, care should be taken to avoid introducing new dependencies, especially with the introduction of modules. Note thatgo mod tidy
looks across all build tags, so+build gofuzz
does not reduce module dependencies.For reference, here is a gist showing the diff between dvyukov/go-fuzz-corpus/tiff/tiff.go and the final form of that file as merged into
golang/x/image
repo as part of #30719. For the first two listed above (image/png
andimage/jpeg
), hopefully it would be as straightforward as that diff illustrates.For
dvyukov/go-fuzz-corpus/gif
, it currently depends on "github.com/dvyukov/go-fuzz-corpus/fuzz" for a utility functionfuzz.DeepEqual
. I think that dependency ondvyukov/go-fuzz-corpus
would need to be eliminated prior to puttinggo-fuzz-corpus/gif/gif.go
into the standard library. Possible solutions might be: (a) to start, that piece of theFuzz
function could simply be eliminated for now, or (b) a roughly correspondingDeepEqual
from the standard library could be substituted, or (c) thatgithub.com/dvyukov/go-fuzz-corpus/fuzz
utility function could temporarily be placed directly inimage/gif/fuzz.go
, or (d) some other solution.Happy to discuss any aspect of this, and of course happy to be corrected if any of the above is different than how people would like to proceed here.
CC @dvyukov @josharian @nigeltao @FiloSottile @acln0
The text was updated successfully, but these errors were encountered: