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

testing: "unknown encoding version" error / provide documentation on the fuzz input file format #49299

Open
kevinburke opened this issue Nov 2, 2021 · 2 comments

Comments

@kevinburke
Copy link
Contributor

@kevinburke kevinburke commented Nov 2, 2021

I'm trying to seed inputs to the fuzzer by adding files to testdata/fuzz, per the documentation.

Here is my test file (for package github.com/kevinburke/ssh_config):

package ssh_config

import (
	"bytes"
	"testing"
)

func FuzzDecode(f *testing.F) {
	f.Fuzz(func(t *testing.T, in []byte) {
		_, err := Decode(bytes.NewReader(in))
		if err != nil {
			t.Fatalf("decode %q: %v", string(in), err)
		}
	})
}

Per the documentation, I tried copying existing files in testdata/config1 and testdata/config2 to testdata/fuzz/Decode. This failed because I should have put them in testdata/fuzz/FuzzDecode but that (repetition of the word "fuzz") wasn't obvious to me from the docs.

I then tried running the fuzzer on Go tip (629ffeb) and got:

--- FAIL: FuzzDecode (0.00s)
    fuzz_test.go:9: "testdata/fuzz/FuzzDecode/config1": unmarshal: unknown encoding version: Host localhost 127.0.0.1 # A comment at the end of a host line.
        "testdata/fuzz/FuzzDecode/config2": unmarshal: unknown encoding version: #	$OpenBSD: ssh_config,v 1.30 2016/02/20 23:06:23 sobrado Exp $

I'm not sure how to resolve that. The docs that I saw (the blog post and in src/testing/testing.go) didn't mention anything about a version format for seed files, and the error message does not explain how to resolve the issue.

I also tried searching Google for information if other people had run into the error, and didn't find any.

Updates #49229.

@kevinburke kevinburke changed the title testing: provide documentation on the fuzz input file format testing: "unknown encoding version" error / provide documentation on the fuzz input file format Nov 2, 2021
@thanm
Copy link
Contributor

@thanm thanm commented Nov 2, 2021

Loading

@katiehockman
Copy link
Member

@katiehockman katiehockman commented Nov 2, 2021

Thanks @kevinburke for reporting this. The corpus files do have a specific version format, and binary files can be converted using https://github.com/golang/tools/blob/master/cmd/file2fuzz/main.go.

We still need to document this, so I can leave this open for documentation purposes.

Loading

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

Successfully merging a pull request may close this issue.

None yet
4 participants