Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upFuzz test Prometheus #667
Comments
This comment has been minimized.
This comment has been minimized.
|
Arguably, this is more a |
This comment has been minimized.
This comment has been minimized.
|
The query language could use a run as well ;) On Wed, Jul 15, 2015 at 1:35 PM Björn Rabenstein notifications@github.com
|
This comment has been minimized.
This comment has been minimized.
|
Played a bit with the package promql
// +build gofuzz
const (
fuzz_interesting = 1
fuzz_meh = 0
fuzz_discard = -1
)
// Fuzz the promql parser
func Fuzz(input []byte) int {
str := string(input)
// Parse as metric
_, err := ParseMetric(str)
if err == nil {
return fuzz_interesting
}
// What about a selector
_, err = ParseMetricSelector(str)
if err == nil {
return fuzz_interesting
}
_, err = ParseExpr(str)
if err == nil {
return fuzz_interesting
}
_, err = ParseStmts(str)
if err == nil {
return fuzz_interesting
}
return fuzz_discard
}I then gave it a small input corpus in Then I ran I got a few hundred crashing examples from running it in half an hour or so, but it looks like the stack traces are all over the place, so I'm a bit hesitant to begin opening bug-reports left and right. Also, this doesn't keep track of which parser crashes, making triage more difficult. Right now I'm trying to do quick runs of the fuzzer with one function at a time and see what I get. |
This was referenced Jul 28, 2015
This comment has been minimized.
This comment has been minimized.
|
Hit in |
This was referenced Jul 28, 2015
This comment has been minimized.
This comment has been minimized.
|
Reported the first cases as separate bugs. One noteworthy find was that no crashes was found in |
This comment has been minimized.
This comment has been minimized.
|
@msiebuhr This is brilliant, thanks so much! This is exactly what we were hoping for (well, uh, not the crashes, they are bad, but that uncovering them works so well like this). @fabxc is on vacation this week and back on Monday, so it might take us a bit to get to them all, but we'll definitely address all of these soon! Fuzzing results are scary... |
This comment has been minimized.
This comment has been minimized.
|
I'd be happy to make a pull-request w. some tidying up, documentation &c, if you're interested. Also, go-fuzz mentions that "thousand[s] of inputs is fine", while I started out with the five above; I have a hunch that more variety would be nice. |
This comment has been minimized.
This comment has been minimized.
|
Fantastic! Definitely great work. A pull request would, of course, be awesome. On Wed, Jul 29, 2015, 8:20 AM Morten Siebuhr notifications@github.com
|
This comment has been minimized.
This comment has been minimized.
|
I've put my work in a branch, https://github.com/msiebuhr/prometheus/tree/fuzz/promql, with a fuzzer-function for each parser + small corpuses for ParseMetric and ParseExpr:
From my (limited) experience, the fuzzer really improves with larger corpuses. So far I've mostly copy-pasted from the test-suites. I thought about just writing out the files directly from the test-suite, but I'm getting a bit too tired to hammer that out. I also poked a bit at setting up the Makefile, but I screwed something up somewhere and thought it would be better to polish the working parts a bit more and get it out. |
This comment has been minimized.
This comment has been minimized.
|
I've created an in-progress pullrequest over at #945. |
brian-brazil
added
the
enhancement
label
Dec 16, 2015
fabxc
added
kind/enhancement
and removed
enhancement
labels
Apr 28, 2016
brian-brazil
added
the
priority/P3
label
Jul 14, 2017
This comment has been minimized.
This comment has been minimized.
|
I believe we still need to make this vaguely automatic. |
fabxc commentedMay 2, 2015
Just found this new tool for Go: https://github.com/dvyukov/go-fuzz
Given that it found quite a few bugs in the standard library, we will certainly find some stuff in Prometheus. Especially as we are now using two
text/templatestyle parsers ourselves that might suffer from very similar bugs as the ones found in the stdlib.