Skip to content

Commit

Permalink
alpine: add max metadata size to fuzzer (#1571)
Browse files Browse the repository at this point in the history
Signed-off-by: AdamKorcz <adam@adalogics.com>
  • Loading branch information
AdamKorcz authored Jun 30, 2023
1 parent 9c13e97 commit 7616da1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
3 changes: 1 addition & 2 deletions pkg/types/alpine/apk_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@ func TestAlpinePackage(t *testing.T) {
}

func TestAlpineMetadataSize(t *testing.T) {
os.Setenv("MAX_APK_METADATA_SIZE", "10")
viper.AutomaticEnv()
viper.Set("max_apk_metadata_size", 10)

inputArchive, err := os.Open("tests/test_alpine.apk")
if err != nil {
Expand Down
10 changes: 10 additions & 0 deletions pkg/types/alpine/fuzz_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,22 @@ package alpine

import (
"bytes"
"fmt"
"testing"

"github.com/spf13/viper"

fuzz "github.com/AdamKorcz/go-fuzz-headers-1"
utils "github.com/sigstore/rekor/pkg/fuzz"
)

func init() {
viper.Set("max_apk_metadata_size", 60000)
if viper.GetUint64("max_apk_metadata_size") != 60000 {
panic(fmt.Sprintf("max metadata size is not defined: %d", viper.GetUint64("max_apk_metadata_size")))
}
}

// FuzzPackageUnmarshal implements the fuzz test
func FuzzPackageUnmarshal(f *testing.F) {
f.Fuzz(func(t *testing.T, data []byte) {
Expand Down

0 comments on commit 7616da1

Please sign in to comment.