moby/pkg/archive/fuzz_test.go
AdamKorcz 93fa093122
testing: move fuzzers over from OSS-Fuzz
Signed-off-by: AdamKorcz <adam@adalogics.com>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-11-30 17:31:03 +01:00

39 lines
749 B
Go

package archive
import (
"bytes"
"testing"
fuzz "github.com/AdaLogics/go-fuzz-headers"
)
func FuzzDecompressStream(f *testing.F) {
f.Fuzz(func(t *testing.T, data []byte) {
r := bytes.NewReader(data)
_, _ = DecompressStream(r)
})
}
func FuzzUntar(f *testing.F) {
f.Fuzz(func(t *testing.T, data []byte) {
ff := fuzz.NewConsumer(data)
tarBytes, err := ff.TarBytes()
if err != nil {
return
}
options := &TarOptions{}
err = ff.GenerateStruct(options)
if err != nil {
return
}
tmpDir := t.TempDir()
Untar(bytes.NewReader(tarBytes), tmpDir, options)
})
}
func FuzzApplyLayer(f *testing.F) {
f.Fuzz(func(t *testing.T, data []byte) {
tmpDir := t.TempDir()
_, _ = ApplyLayer(tmpDir, bytes.NewReader(data))
})
}