Skip to content

Commit

Permalink
fuzzing: improve cose fuzzer
Browse files Browse the repository at this point in the history
Signed-off-by: AdamKorcz <adam@adalogics.com>
  • Loading branch information
AdamKorcz committed Jan 26, 2023
1 parent 187df73 commit 75606f8
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 8 deletions.
32 changes: 25 additions & 7 deletions pkg/types/cose/fuzz_test.go → pkg/types/cose/v0.0.1/fuzz_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,36 @@ import (
"sync"
"testing"

fuzz "github.com/AdaLogics/go-fuzz-headers"

fuzzUtils "github.com/sigstore/rekor/pkg/fuzz"
"github.com/sigstore/rekor/pkg/types"
"github.com/sigstore/rekor/pkg/types/cose"
)

var initter sync.Once

func FuzzCreateProposedEntry(f *testing.F) {
f.Fuzz(func(t *testing.T, version string) {
func FuzzCoseCreateProposedEntry(f *testing.F) {
f.Fuzz(func(t *testing.T, propsData []byte) {
initter.Do(fuzzUtils.SetFuzzLogger)
ctx := context.Background()
brt := New()
props := types.ArtifactProperties{}
_, _ = brt.CreateProposedEntry(ctx, version, props)

version := "0.0.1"

ff := fuzz.NewConsumer(propsData)

props, cleanup, err := fuzzUtils.CreateProps(ff)
if err != nil {
t.Skip()
}
defer cleanup()

it := cose.New()
entry, err := it.CreateProposedEntry(context.Background(), version, props)
if err != nil {
t.Skip()
}
_, err = it.UnmarshalEntry(entry)
if err != nil {
t.Skip()
}
})
}
2 changes: 1 addition & 1 deletion tests/oss_fuzz.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ compile_native_go_fuzzer github.com/sigstore/rekor/pkg/sharding FuzzValidateUUID
compile_native_go_fuzzer github.com/sigstore/rekor/pkg/sharding FuzzValidateTreeID FuzzValidateTreeID
compile_native_go_fuzzer github.com/sigstore/rekor/pkg/sharding FuzzValidateEntryID FuzzValidateEntryID
compile_native_go_fuzzer github.com/sigstore/rekor/pkg/signer FuzzNewFile FuzzNewFile
compile_native_go_fuzzer github.com/sigstore/rekor/pkg/types/cose FuzzCreateProposedEntry FuzzCreateProposedEntry
compile_native_go_fuzzer github.com/sigstore/rekor/pkg/types/cose/v0.0.1 FuzzCoseCreateProposedEntry FuzzCoseCreateProposedEntry
compile_native_go_fuzzer github.com/sigstore/rekor/pkg/types/alpine FuzzPackageUnmarshal FuzzPackageUnmarshal
compile_native_go_fuzzer github.com/sigstore/rekor/pkg/types/jar FuzzJarUnmarshal FuzzJarUnmarshal
compile_native_go_fuzzer github.com/sigstore/rekor/pkg/types/hashedrekord FuzzHashedRekord FuzzHashedRekord
Expand Down

0 comments on commit 75606f8

Please sign in to comment.