Skip to content

Commit

Permalink
jar type: add fuzzer
Browse files Browse the repository at this point in the history
Signed-off-by: AdamKorcz <adam@adalogics.com>
  • Loading branch information
AdamKorcz committed Nov 22, 2022
1 parent bd1452b commit 7982dea
Show file tree
Hide file tree
Showing 3 changed files with 107 additions and 0 deletions.
41 changes: 41 additions & 0 deletions pkg/signer/fuzz_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
Copyright The Rekor Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package signer

import (
"os"
"testing"
)

func FuzzNewFile(f *testing.F) {
f.Fuzz(func(t *testing.T, keyData []byte, keyPass string) {
f, err := os.Create("keyfile")
if err != nil {
t.Skip()
}
_, err = f.Write(keyData)
if err != nil {
t.Skip()
}
defer func() {
f.Close()
os.Remove("keyfile")
}()

_, _ = NewFile("keyfile", keyPass)
})
}
32 changes: 32 additions & 0 deletions pkg/types/cose/fuzz_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
//
// Copyright 2022 The Sigstore Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package cose

import (
"context"
"testing"

"github.com/sigstore/rekor/pkg/types"
)

func FuzzCreateProposedEntry(f *testing.F) {
f.Fuzz(func(t *testing.T, version string) {
ctx := context.Background()
brt := New()
props := types.ArtifactProperties{}
_, _ = brt.CreateProposedEntry(ctx, version, props)
})
}
34 changes: 34 additions & 0 deletions pkg/types/jar/fuzz_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
//
// Copyright 2022 The Sigstore Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package jar

import (
"testing"

"github.com/sigstore/rekor/pkg/generated/models"
)

func FuzzJarUnmarshal(f *testing.F) {
f.Fuzz(func(t *testing.T, raw []byte) {
m := &models.Jar{}
err := m.UnmarshalJSON(raw)
if err != nil {
t.Skip()
}
brt := New()
brt.UnmarshalEntry(m)
})
}

0 comments on commit 7982dea

Please sign in to comment.