go-fuzz icon indicating copy to clipboard operation
go-fuzz copied to clipboard

Question: JSON (or any other structured) output for `go-fuzz` ?

Open ghost opened this issue 9 years ago • 11 comments

This would allow one of my tool to more easily parse the output of go-fuzz. I'll actually do the hard work via a PR I just want to know if you're open to it before starting.

ghost avatar Jun 30 '16 19:06 ghost

Can you parse the existing eventSource thing? It should be already exposing stats in json.

dvyukov avatar Jul 01 '16 09:07 dvyukov

2015/04/25 12:39:53 slaves: 500, corpus: 186 (42s ago), crashers: 3,
 restarts: 1/8027, execs: 12009519 (121224/sec), cover: 2746, uptime: 1m39s

The only output I see is this, am I missing some flag or something ?

ghost avatar Jul 05 '16 07:07 ghost

ok I see what you mean now

so /eventSource is a streaming and I would like a single GET request that returns immediately, also ideally it would be in stdout so I don't have to manage all the go-fuzz port. Also for some reason the / endpoint just crashes. I don't know if that's what I'm looking for but here's the crash anyway

2016/07/05 04:00:16 http: panic serving 127.0.0.1:53066: runtime error: invalid memory address or nil pointer dereference
goroutine 170 [running]:
net/http.(*conn).serve.func1(0xc82007c500)
    /usr/local/go/src/net/http/server.go:1389 +0xc1
panic(0x482400, 0xc8200140d0)
    /usr/local/go/src/runtime/panic.go:426 +0x4e9
github.com/elazarl/go-bindata-assetfs.(*AssetFS).Open(0xc820117170, 0xc8201704e0, 0x11, 0x0, 0x0, 0x0, 0x0)
    /Users/hydroflame/software/go/src/github.com/elazarl/go-bindata-assetfs/assetfs.go:148 +0x22e
net/http.serveFile(0xd84968, 0xc820062820, 0xc82010c540, 0xd849c8, 0xc820117170, 0x522f70, 0xb, 0xc820116601)
    /usr/local/go/src/net/http/fs.go:364 +0x158
net/http.(*fileHandler).ServeHTTP(0xc820124620, 0xd84968, 0xc820062820, 0xc82010c540)
    /usr/local/go/src/net/http/fs.go:517 +0x19c
main.(*Master).index(0xc82012e080, 0xd84968, 0xc820062820, 0xc82010c540)
    /Users/hydroflame/gopath/src/github.com/dvyukov/go-fuzz/go-fuzz/master.go:134 +0x176
main.(*Master).(main.index)-fm(0xd84968, 0xc820062820, 0xc82010c540)
    /Users/hydroflame/gopath/src/github.com/dvyukov/go-fuzz/go-fuzz/master.go:77 +0x3e
net/http.HandlerFunc.ServeHTTP(0xc820014f10, 0xd84968, 0xc820062820, 0xc82010c540)
    /usr/local/go/src/net/http/server.go:1618 +0x3a
net/http.(*ServeMux).ServeHTTP(0xc820012c00, 0xd84968, 0xc820062820, 0xc82010c540)
    /usr/local/go/src/net/http/server.go:1910 +0x17d
net/http.serverHandler.ServeHTTP(0xc82012e300, 0xd84968, 0xc820062820, 0xc82010c540)
    /usr/local/go/src/net/http/server.go:2081 +0x19e
net/http.(*conn).serve(0xc82007c500)
    /usr/local/go/src/net/http/server.go:1472 +0xf2e
created by net/http.(*Server).Serve
    /usr/local/go/src/net/http/server.go:2137 +0x44e

ghost avatar Jul 05 '16 08:07 ghost

oh FYI the tool I'm making is github.com/hydroflame/fuzzi

ghost avatar Jul 05 '16 08:07 ghost

I would like a single GET request that returns immediately, also ideally it would be in stdout

So what do you need? A GET request or stdout?

I am just concerned about the number of ways go-fuzz exposes stats: stdout, web interface, /eventSource. Would it be possible to combine/replace one of the existing mechanisms?

dvyukov avatar Jul 05 '16 10:07 dvyukov

Re Fuzzi: looks like a great idea. In some cases we use fuzzer for unit testing. Namely: you can run it in continuous mode, use coverage and enlarge corpus; or you can run it in unit-test mode when it just executes all inputs in the corpus once and finishes. Such mode is great for finding regressions. Don't know if it fits Fuzzi use cases.

dvyukov avatar Jul 05 '16 10:07 dvyukov

So what do you need? A GET request or stdout?

So what I want is to expose an endpoint that returns the stats of a particular fuzz instance as json (or any other structure format for what I care). So right now I have this thing called linewriter which implements io.Writer and always keeps the last line that was written to it. I dont currently parse the stdout output of go-fuzz, simply blit it to http.ResponseWriter. If possible, it would be nice that either go-fuzz has an endpoint that isn't text-streaming (it would simply blit the stats once) or even better have a flag so that go-fuzz outputs json directly (and then I can still use something like my line writer. I don't need both, in fact I don't need either of these but one of them would be nice. The advantage of printing json to stdout is that fuzzi wouldn't need to manage ports (since multiple instance of go-fuzz may be running on a fuzzi server)

re unit testing: If the person just wants to run the regression and exit, it doesn't really work with fuzzi. There is no reason why they wouldn't be able to do that with just standard go-fuzz. HOWEVER, if they wanted to ask fuzzi to do the regression, get the result and then have fuzzi continue fuzzing until the next CI job triggers, then yeah that would play well with it.

Thing is ... I don't know how to execute regression testing with go-fuzz :P

ghost avatar Jul 05 '16 17:07 ghost

Thing is ... I don't know how to execute regression testing with go-fuzz :P

Such mode does not exist in go-fuzz. Should be possible to add. But there must be somebody willing to use it.

dvyukov avatar Jul 06 '16 07:07 dvyukov

So what I want is to expose an endpoint that returns the stats of a particular fuzz instance as json (or any other structure format for what I care).

Why can't you parse the current:

hub: corpus=544 bootstrap=544 fuzz=0 minimize=0 versifier=0 smash=0 sonar=0

? Looks pretty machine-parsable to me. We could unify format of other output lines if necessary.

dvyukov avatar Jul 06 '16 07:07 dvyukov

hub: corpus=544 bootstrap=544 fuzz=0 minimize=0 versifier=0 smash=0 sonar=0

Where does that come from ?

ghost avatar Jul 06 '16 08:07 ghost

Where does that come from ?

From -v=1 flag. But we can change the other output line as well.

dvyukov avatar Jul 06 '16 08:07 dvyukov