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

Fuzz parsers #945

Merged
merged 6 commits into from
May 11, 2016
Merged

Fuzz parsers #945

merged 6 commits into from
May 11, 2016

Conversation

msiebuhr
Copy link
Contributor

Still missing

  • No corpus for ParseMetricSelector and ParseStmts. Should be done by writing test-cases to the appropriate files.
  • No makefile-stuff is set up.

@msiebuhr
Copy link
Contributor Author

In-progess pull, related to #667.

@juliusv
Copy link
Member

juliusv commented Jul 30, 2015

Looks great in general, thanks! Though I want @fabxc to take a final look.

Will just make a couple of minor style comments now...

@@ -0,0 +1,67 @@
package promql
// +build gofuzz
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couple of style nits:

@fabxc
Copy link
Contributor

fabxc commented Aug 3, 2015

In general what @juliusv said.
The test corpus can always be extended later.

Don't mind about not having the Makefile stuff setup. I'm weirded out by the constant aliasing of trivial commands anyway – you cannot use them anyway once you want to add an extra flag or such.

func FuzzParseExpr(in []byte) int {
_, err := ParseExpr(string(in))

if err == nil {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: let's remove the blanks above the ifs for consistency with our other code.

@fabxc
Copy link
Contributor

fabxc commented Aug 4, 2015

Looks good so far.

#949 turns runtime panics into an "unexpected error". This is still always a bug so the code has to be adjusted to turn this back into a panic.

@fabxc
Copy link
Contributor

fabxc commented Aug 6, 2015

Please ping if you made changes so I know to take another look :)

What we still need is something like

if err.Error() == "unexpected error" {
    panic(err)
}

@juliusv
Copy link
Member

juliusv commented Aug 6, 2015

Wouldn't it be better to use the variable errUnexpected for that comparison or does that not work for some reason?

@fabxc
Copy link
Contributor

fabxc commented Aug 6, 2015

Yes :) forgot that I turned it into a variable recently.

On Thu, Aug 6, 2015 at 12:26 PM Julius Volz notifications@github.com
wrote:

Wouldn't it be better to use the variable errUnexpected for that
comparison or does that not work for some reason?


Reply to this email directly or view it on GitHub
#945 (comment)
.

@fabxc
Copy link
Contributor

fabxc commented Aug 11, 2015

@msiebuhr ping.

You are probably busy but it would be really cool to have all your efforts merged :)

@fabxc
Copy link
Contributor

fabxc commented Apr 29, 2016

Someone should take over this PR as it is really useful.

@msiebuhr
Copy link
Contributor Author

I had totally forgotten about this!

Currently, I don't really have enough spare bandwidth to take care of this. I might get around to look at it in a few weeks time, but I can't make any promises.

@msiebuhr
Copy link
Contributor Author

I've done a quick update on the branch, but it invariably gives me an import error when I try to build it:

>go-fuzz-build -func FuzzParseMetric -o FuzzParseMetric.zip github.com/prometheus/prometheus/promql
can't find imported package github.com/prometheus/common/model
>go-fuzz-build -func FuzzParseMetric -o FuzzParseMetric.zip github.com/prometheus/prometheus/promql
can't find imported package github.com/golang/protobuf/proto
>go-fuzz-build -func FuzzParseMetric -o FuzzParseMetric.zip github.com/prometheus/prometheus/promql
can't find imported package github.com/syndtr/goleveldb/leveldb/util

@msiebuhr
Copy link
Contributor Author

I'm suspecting this is a consequence of dvyukov/go-fuzz#127, but I can't tell for certain.

@msiebuhr
Copy link
Contributor Author

msiebuhr commented May 10, 2016

Turned out it was a vendoring-related bug in the fuzzer. Things should now work...

(And Dmitry kindly gave some tips on how to improve things somewhat, which I'm incorporating too.)

@fabxc
Copy link
Contributor

fabxc commented May 11, 2016

Cool, thanks a lot for picking this back up.
Can this be merged already or do you want to add any more tweaks?

@msiebuhr
Copy link
Contributor Author

I can't readily come up the anything to change...

@fabxc
Copy link
Contributor

fabxc commented May 11, 2016

Okay, thanks. Wasn't sure because of your last comment.

@fabxc fabxc merged commit bbc4f11 into prometheus:master May 11, 2016
@msiebuhr msiebuhr deleted the fuzz branch May 11, 2016 18:24
@msiebuhr
Copy link
Contributor Author

msiebuhr commented May 11, 2016

@fabxc Great! I applied the changes in ffc8cab...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants