diff --git a/internal/handler/handler_fuzz_test.go b/internal/handler/handler_fuzz_test.go index ff38b11..66d225b 100644 --- a/internal/handler/handler_fuzz_test.go +++ b/internal/handler/handler_fuzz_test.go @@ -24,11 +24,6 @@ import ( "go.uber.org/zap" ) -const ( - fuzzSuccessExitCode = 0 - fuzzFailExitCode = -1 -) - func prepareStrings(tp *go_fuzz_utils.TypeProvider, count int) ([]string, error) { array := make([]string, count) var err error @@ -222,23 +217,18 @@ func InitFuzzUpload() { } -func DoFuzzUpload(input []byte) int { +func DoFuzzUpload(input []byte) { // FUZZER INIT if len(input) < 100 { - return fuzzFailExitCode + return } tp, err := go_fuzz_utils.NewTypeProvider(input) if err != nil { - return fuzzFailExitCode + return } - _, _, _, _, _, _, _, err = upload(tp) - if err != nil { - return fuzzFailExitCode - } - - return fuzzSuccessExitCode + _, _, _, _, _, _, _, _ = upload(tp) } func FuzzUpload(f *testing.F) { @@ -307,30 +297,28 @@ func InitFuzzGet() { } -func DoFuzzGet(input []byte) int { +func DoFuzzGet(input []byte) { // FUZZER INIT if len(input) < 100 { - return fuzzFailExitCode + return } tp, err := go_fuzz_utils.NewTypeProvider(input) if err != nil { - return fuzzFailExitCode + return } ctx, hc, cnrID, resp, filename, _, _, err := upload(tp) if err != nil { - return fuzzFailExitCode + return } r, err := downloadOrHead(tp, ctx, hc, cnrID, resp, filename) if err != nil { - return fuzzFailExitCode + return } hc.Handler().DownloadByAddressOrBucketName(r) - - return fuzzSuccessExitCode } func FuzzGet(f *testing.F) { @@ -343,30 +331,28 @@ func InitFuzzHead() { } -func DoFuzzHead(input []byte) int { +func DoFuzzHead(input []byte) { // FUZZER INIT if len(input) < 100 { - return fuzzFailExitCode + return } tp, err := go_fuzz_utils.NewTypeProvider(input) if err != nil { - return fuzzFailExitCode + return } ctx, hc, cnrID, resp, filename, _, _, err := upload(tp) if err != nil { - return fuzzFailExitCode + return } r, err := downloadOrHead(tp, ctx, hc, cnrID, resp, filename) if err != nil { - return fuzzFailExitCode + return } hc.Handler().HeadByAddressOrBucketName(r) - - return fuzzSuccessExitCode } func FuzzHead(f *testing.F) { @@ -379,36 +365,36 @@ func InitFuzzDownloadByAttribute() { } -func DoFuzzDownloadByAttribute(input []byte) int { +func DoFuzzDownloadByAttribute(input []byte) { // FUZZER INIT if len(input) < 100 { - return fuzzFailExitCode + return } tp, err := go_fuzz_utils.NewTypeProvider(input) if err != nil { - return fuzzFailExitCode + return } ctx, hc, cnrID, _, _, attrKey, attrVal, err := upload(tp) if err != nil { - return fuzzFailExitCode + return } cid := cnrID.EncodeToString() cid, err = maybeFillRandom(tp, cid) if err != nil { - return fuzzFailExitCode + return } attrKey, err = maybeFillRandom(tp, attrKey) if err != nil { - return fuzzFailExitCode + return } attrVal, err = maybeFillRandom(tp, attrVal) if err != nil { - return fuzzFailExitCode + return } r := new(fasthttp.RequestCtx) @@ -418,8 +404,6 @@ func DoFuzzDownloadByAttribute(input []byte) int { r.SetUserValue("attr_val", attrVal) hc.Handler().DownloadByAttribute(r) - - return fuzzSuccessExitCode } func FuzzDownloadByAttribute(f *testing.F) { @@ -432,36 +416,36 @@ func InitFuzzHeadByAttribute() { } -func DoFuzzHeadByAttribute(input []byte) int { +func DoFuzzHeadByAttribute(input []byte) { // FUZZER INIT if len(input) < 100 { - return fuzzFailExitCode + return } tp, err := go_fuzz_utils.NewTypeProvider(input) if err != nil { - return fuzzFailExitCode + return } ctx, hc, cnrID, _, _, attrKey, attrVal, err := upload(tp) if err != nil { - return fuzzFailExitCode + return } cid := cnrID.EncodeToString() cid, err = maybeFillRandom(tp, cid) if err != nil { - return fuzzFailExitCode + return } attrKey, err = maybeFillRandom(tp, attrKey) if err != nil { - return fuzzFailExitCode + return } attrVal, err = maybeFillRandom(tp, attrVal) if err != nil { - return fuzzFailExitCode + return } r := new(fasthttp.RequestCtx) @@ -471,8 +455,6 @@ func DoFuzzHeadByAttribute(input []byte) int { r.SetUserValue("attr_val", attrVal) hc.Handler().HeadByAttribute(r) - - return fuzzSuccessExitCode } func FuzzHeadByAttribute(f *testing.F) { @@ -485,32 +467,32 @@ func InitFuzzDownloadZipped() { } -func DoFuzzDownloadZipped(input []byte) int { +func DoFuzzDownloadZipped(input []byte) { // FUZZER INIT if len(input) < 100 { - return fuzzFailExitCode + return } tp, err := go_fuzz_utils.NewTypeProvider(input) if err != nil { - return fuzzFailExitCode + return } ctx, hc, cnrID, _, _, _, _, err := upload(tp) if err != nil { - return fuzzFailExitCode + return } cid := cnrID.EncodeToString() cid, err = maybeFillRandom(tp, cid) if err != nil { - return fuzzFailExitCode + return } prefix := "" prefix, err = maybeFillRandom(tp, prefix) if err != nil { - return fuzzFailExitCode + return } r := new(fasthttp.RequestCtx) @@ -519,8 +501,6 @@ func DoFuzzDownloadZipped(input []byte) int { r.SetUserValue("prefix", prefix) hc.Handler().DownloadZip(r) - - return fuzzSuccessExitCode } func FuzzDownloadZipped(f *testing.F) { @@ -533,21 +513,21 @@ func InitFuzzStoreBearerTokenAppCtx() { } -func DoFuzzStoreBearerTokenAppCtx(input []byte) int { +func DoFuzzStoreBearerTokenAppCtx(input []byte) { // FUZZER INIT if len(input) < 100 { - return fuzzFailExitCode + return } tp, err := go_fuzz_utils.NewTypeProvider(input) if err != nil { - return fuzzFailExitCode + return } prefix := "" prefix, err = maybeFillRandom(tp, prefix) if err != nil { - return fuzzFailExitCode + return } ctx := context.Background() @@ -570,8 +550,6 @@ func DoFuzzStoreBearerTokenAppCtx(input []byte) int { } tokens.StoreBearerTokenAppCtx(ctx, r) - - return fuzzSuccessExitCode } func FuzzStoreBearerTokenAppCtx(f *testing.F) {