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

Closed
kevinburke opened this issue Nov 2, 2021 · 3 comments
Labels
Documentation fuzz Issues related to native fuzzing support NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@kevinburke
Copy link
Contributor

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 thanm added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Nov 2, 2021
@thanm
Copy link
Contributor

thanm commented Nov 2, 2021

@katiehockman

@katiehockman
Copy link
Contributor

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.

@katiehockman katiehockman added NeedsFix The path to resolution is known, but the work has not been done. fuzz Issues related to native fuzzing support and removed NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. labels Nov 2, 2021
@katiehockman katiehockman added this to the Go1.18 milestone Nov 2, 2021
@katiehockman
Copy link
Contributor

katiehockman commented Dec 6, 2021

I'm going to close this as a dupe of #48717, since at this point it is going to be a doc change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Documentation fuzz Issues related to native fuzzing support NeedsFix The path to resolution is known, but the work has not been done.
Projects
Status: No status
Development

No branches or pull requests

4 participants