github.com/moby/docker@v26.1.3+incompatible/pkg/archive/fuzz_test.go (about) 1 package archive 2 3 import ( 4 "bytes" 5 "testing" 6 7 fuzz "github.com/AdaLogics/go-fuzz-headers" 8 ) 9 10 func FuzzDecompressStream(f *testing.F) { 11 f.Fuzz(func(t *testing.T, data []byte) { 12 r := bytes.NewReader(data) 13 _, _ = DecompressStream(r) 14 }) 15 } 16 17 func FuzzUntar(f *testing.F) { 18 f.Fuzz(func(t *testing.T, data []byte) { 19 ff := fuzz.NewConsumer(data) 20 tarBytes, err := ff.TarBytes() 21 if err != nil { 22 return 23 } 24 options := &TarOptions{} 25 err = ff.GenerateStruct(options) 26 if err != nil { 27 return 28 } 29 tmpDir := t.TempDir() 30 Untar(bytes.NewReader(tarBytes), tmpDir, options) 31 }) 32 } 33 34 func FuzzApplyLayer(f *testing.F) { 35 f.Fuzz(func(t *testing.T, data []byte) { 36 tmpDir := t.TempDir() 37 _, _ = ApplyLayer(tmpDir, bytes.NewReader(data)) 38 }) 39 }