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: improve cose fuzzer #1300

Merged
merged 1 commit into from
Jan 27, 2023
Merged
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
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