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

[Fuzzing] Update the fuzzing suite to native Go-Fuzz #212

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ fmt: ## Run go fmt against code
tests: ## Run all tests and requires a running rabbitmq-server. Use GO_TEST_FLAGS to add extra flags to go test
go test -race -v -tags integration $(GO_TEST_FLAGS)

.PHONY: fuzzing
fuzzing: ## Run fuzzing tests
go test -fuzz=FuzzReadFrame .

.PHONY: tests-docker
tests-docker: rabbitmq-server
RABBITMQ_RABBITMQCTL_PATH="DOCKER:$(CONTAINER_NAME)" go test -race -v -tags integration $(GO_TEST_FLAGS)
Expand Down
23 changes: 0 additions & 23 deletions fuzz.go

This file was deleted.

13 changes: 13 additions & 0 deletions read_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
package amqp091

import (
"bytes"
"strings"
"testing"
)
Expand All @@ -29,3 +30,15 @@ func TestGoFuzzCrashers(t *testing.T) {
}
}
}

func FuzzReadFrame(f *testing.F) {

f.Add([]byte("\b000000"))
f.Add([]byte("\x02\x16\x10�[��\t\xbdui�" + "\x10\x01\x00\xff\xbf\xef\xbfサn\x99\x00\x10r"))
f.Add([]byte("\x0300\x00\x00\x00\x040000"))

f.Fuzz(func(t *testing.T, input_data []byte) {
r := reader{bytes.NewReader(input_data)}
_, _ = r.ReadFrame()
})
}